Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
103 views
in Technique[技术] by (71.8m points)

python - What does "Separate source and build directories" mean?

I am trying to use Sphinx for the first time. I am running sphinx-quickstart, but don't understand the first question being asked:

> Separate source and build directories (y/n) [n]: 

What does this mean? What difference does it make whether these directories are separated or not? How do I know which one to choose?

question from:https://stackoverflow.com/questions/65829149/what-does-separate-source-and-build-directories-mean

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Put simply the option "Separate sources from build" of the sphinx-quickstart tool leads to 2 possible directory/file structure layouts:

  1. If you choose "Yes" (to separate), you 'll get one build directory and one source directory:

    The generated .rst files and conf.py are placed in the source directory (afterwards any .rst files you write should also be placed there). The final documentation files (HTML for example) that Sphinx will generate from the reStructuredText source files are placed in the build directory.

    C:.
    │   make.bat
    │   Makefile
    │
    ├───build
    └───source
        │   conf.py
        │   index.rst
        │
        ├───_static
        └───_templates
    

    Here's an excerpt of running the sphinx-quickstart tool choosing "YES" to separate sources from build:

    Creating file C:Your_Projectdocssourceconf.py.
    Creating file C:Your_Projectdocssourceindex.rst.
    Creating file C:Your_ProjectdocsMakefile.
    Creating file C:Your_Projectdocsmake.bat.
    
    Finished: An initial directory structure has been created.
    
  2. If you choose "No" (to not separate), the source directory is not created so the contents that were placed in the source directory choosing the "separate sources" option will instead be placed in the base directory from where you run sphinx-quickstart.

    Also the build directory will be slightly different now having an underscore _build in the name:

    C:.
    │   conf.py
    │   index.rst
    │   make.bat
    │   Makefile
    │
    ├───_build
    ├───_static
    └───_templates
    

    Here's an excerpt of running the sphinx-quickstart tool choosing "NO" to separate sources from build:

    Separate source and build directories (y/n) [n]: 
    
    Creating file C:Your_Projectdocsconf.py.
    Creating file C:Your_Projectdocsindex.rst.
    Creating file C:Your_ProjectdocsMakefile.
    Creating file C:Your_Projectdocsmake.bat.
    
    Finished: An initial directory structure has been created.
    

How do I know which one to choose?

The prevalent option I've seen is choosing to separate sources from build. Keeping the files separate arguably makes things more organized in larger projects. The only drawback is that you'll have more directories, which may seem confusing at first, but the increased separation tends to be worth it in the long run.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...