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.
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
When variable is first, this appears in the docs while the function new_example is ignored.
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
gives
When variable is first, this appears in the docs while the function
new_example
is ignored.