Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parses first element of if __name__ == '__main__' block #429

Open
jsatuit opened this issue Apr 3, 2024 · 0 comments
Open

Parses first element of if __name__ == '__main__' block #429

jsatuit opened this issue Apr 3, 2024 · 0 comments

Comments

@jsatuit
Copy link

jsatuit commented Apr 3, 2024

If a module has an if __name__ == '__main__: block, the first element is analysed and its documentation is generated. The next ones are ignored. This is regardless if it the first a variable or a function.

Uses python 3.11, sphinx-autoapi 3.0.0, Sphinx 7.2.6

I expect the behaviour to be that everything in if __name__ == '__main__: blocks would be ignored like sphinx-autodoc does.

Minimal working example:
Analysing

def normal_function():
    """
    Function with docstring
    """
    pass

if __name__ == '__main__':
    def new_example():
        """
        This function will appear in the docs
        """
        pass
    this_variable_is_ignored = 52

gives

IV50eJKtYclZcZur

When variable is first, this appears in the docs while the function new_example is ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants