sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.5k stars 2.11k forks source link

How to remove top folder from documentation path? #3113

Closed ppasler closed 7 years ago

ppasler commented 7 years ago

I have a python project and a structure like this

project
|-- doc
|-- src
    |-- mod_1.py
    |   |-- Class1    
    |-- package1
        |-- mod_2.py
            |-- Class2

I used sphinx-apidoc to create my documentation and the path to my submodules look like this

src.mod1
src.package2.mod2

Now I wonder, if there is a way to remove the src prefix? To make the path look like this

mod1
package2.mod2

Thanks for any answer! Regards, paul

shimizukawa commented 7 years ago

I guess src/__init__.py file exists in your environment. Please remove the file and try again.

ppasler commented 7 years ago

Hey @shimizukawa, thanks for the fast response. You guessed right :) But after deleting the __init__.py in the src folder. Only one module test is shown in the module index. This is my conf.py (the other files can be found as well), Maybe I made som other mistakes there?

shimizukawa commented 7 years ago

I guess (again), sphinx-apidoc -o doc/ . in project directory you invoked. Please do sphinx-apidoc -o doc/ src/

ppasler commented 7 years ago

@shimizukawa same result. The module.html only show the test module.

shimizukawa commented 7 years ago

I tried with https://github.com/ppasler/current-adas:

$ sphinx-apidoc --version
Sphinx (sphinx-apidoc) 1.4.8
$ ls
Praesentation_wvk15_pasler.pdf  paper
README.md           poster
documentation           project
$ cd project/code/
$ ls
data        examples    js
doc     index.html  src
$ sphinx-apidoc -o doc2 src/
Creating file doc2/src.rst.
Creating file doc2/src.classification.rst.
Creating file doc2/src.config.rst.
Creating file doc2/src.emokit.rst.
Creating file doc2/src.misc.rst.
Creating file doc2/src.output.rst.
Creating file doc2/src.statistic.rst.
Creating file doc2/src.test.rst.
Creating file doc2/src.util.rst.
Creating file doc2/src.window.rst.
Creating file doc2/modules.rst.
$ rm src/__init__.py 
$ sphinx-apidoc -o doc3 src/
Creating file doc3/data_collector.rst.
Creating file doc3/data_processor.rst.
Creating file doc3/eeg_processor.rst.
Creating file doc3/feature_extractor.rst.
Creating file doc3/http_eeg_data_provider.rst.
Creating file doc3/http_eeg_data_receiver.rst.
Creating file doc3/posdbos.rst.
Creating file doc3/classification.rst.
Creating file doc3/config.rst.
Creating file doc3/emokit.rst.
Creating file doc3/misc.rst.
Creating file doc3/output.rst.
Creating file doc3/statistic.rst.
Creating file doc3/test.rst.
Creating file doc3/util.rst.
Creating file doc3/window.rst.
Creating file doc3/modules.rst.

It seems ok.

ppasler commented 7 years ago

Yeah, up to this point it looks fine to me too. But after calling make html the modules.html does not contain the modules.

shimizukawa commented 7 years ago

After tweaking your code as https://github.com/ppasler/current-adas/pull/1 I got another error that caused by environment because my environment doesn't have necessary packages to run your program. Now you can get a result as you expected (maybe).

ppasler commented 7 years ago

@shimizukawa thank you very much! This did the trick - sometimes it's only a line :)