Skip to content
Advertisement

How to exclude imports from automodapi output?

I am trying to use automodapi to generate documentation for my Django project. When I call automodapi like this:

.. automodapi:: mypackage.mymodule

the output includes all imported classes and functions, e.g, the Django Model class, in the index of Functions and Classes. I would like to exclude the imports and only list those classes and functions declared in the module I specified.

I couldn’t see anything about this in the documentation.

Is there a way to do this, preferably without modifying modules?

UPDATE: @saimn has provided a working solution using __all__ but my project doesn’t use __all__. It would be nice if there was a solution that didn’t involve modifying the modules.

Advertisement

Answer

You can use the __all__ variable (this should probably be stated more clearly in the documentation).

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement