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
467 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 Answer

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.


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

2.1m questions

2.1m answers

60 comments

56.9k users

...