Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

python - Remove the word "module" from Sphinx documentation

Using Sphinx for documenting my Python project. I want to remove the word "module" which follows the name of each python file (in the navbar, TOC, the page title, etc).

e.g. Details:

The project is composed of 2 files utils.py and main.py.

In my index.rst file, I use:

.. toctree::
   :maxdepth: 2

   utils
   main

to import both files as "modules". From the docs/ folder, I then call:

sphinx-apidoc -f -o ./source/ .. 
make html

to generate the static site. In the site, the word "module" follows every file name, and I would like to remove it.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Sphinx 2.2 adds templating for the reST files generated by sphinx-apidoc.

Use the --templatedir option to set the path to a dir containing module.rst_t, package.rst_t and toc.rst_t files. The files can be created from the corresponding files in site-packages/sphinx/templates/apidoc.

Then, in package.rst_treplace

{{- [submodule, "module"] | join(" ") | e | heading(2) }}

with

{{- submodule | e | heading(2) }}

Repeat for module.rst_t.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...