8

I'm building my sphinx doc for a django project the following way:

sphinx-apidoc app -o docs/source/app --force

Now it includes all of the South migrations which I don't want to have in my documentation. I now tried to exclude them the following way:

conf.py:
    def skip_migrations(app, what, name, obj, skip, options):
        return skip or (what == 'module' and name.find('Migration') != -1)\ 
               or str(obj).find('migrations') != -1

    def setup(app):
       app.connect('autodoc-skip-member', skip_migrations)

Now they aren't documented anymore, but are still listed under modules. How can I exclude them?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
melbic
  • 11,988
  • 5
  • 33
  • 37

2 Answers2

6

You may exclude the rst files created for the migrations by adding them to the exclude_pattern in your conf.py file:

exclude_patterns = ["**/*.migrations.rst",]
hellphil
  • 415
  • 6
  • 10
2

Just avoid generating the .rst files with sphinx-apidoc in the first place:

sphinx-apidoc app -o docs/source/app --force */migrations/*

Patterns added after the module name are understood as excluded paths.

pintoch
  • 2,293
  • 1
  • 18
  • 26
  • 1
    For those that come after me: The `--force` needs to be before the `-o` or else this command will fail. As explained in [this issue](https://github.com/sphinx-doc/sphinx/issues/4771) it has something to do with argparse. – gallen Nov 22 '19 at 07:31