Skip to content Skip to sidebar Skip to footer

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. Detail

Solution 1:

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.

Solution 2:

One possible solution uses JS to find & replace the word "module" after the page loads:

Create a file source/_templates/layout.html with the following content:

{% extends "!layout.html" %}
{% block extrahead %}
<scripttype="text/javascript">window.onload = function() {
    document.body.innerHTML = document.body.innerHTML.replace(/ module/g, '');
  }
</script>
{% endblock %}

Make sure that conf.py has templates_path = ['_templates'] set, then Sphinx will append the script to the <head> of all documentation pages, and voila!

Post a Comment for "Remove The Word "module" From Sphinx Documentation"