删除单词" module"来自Sphinx文档

时间:2018-05-16 01:27:45

标签: python python-sphinx

使用Sphinx记录我的Python项目。我想删除" module" 这个词,它跟在每个python文件的名称后面(在导航栏中,TOC,页面标题等)。

e.g。详细说明:

该项目由2个文件utils.pymain.py组成。

在我的index.rst文件中,我使用:

.. toctree::
   :maxdepth: 2

   utils
   main

将这两个文件导入为" modules"。从docs/文件夹中,我然后调用:

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

生成静态站点。在网站上,单词" module"跟随每个文件名,我想将其删除。

2 个答案:

答案 0 :(得分:3)

Sphinx 2.2为docker run --name newnifi -p 8080:8080 -d apache/nifi:latest2 生成的reST文件添加了模板。

使用import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; public class prodConsumeJava8 { public static void main(String[] args) { BlockingQueue<Integer> que=new LinkedBlockingQueue<>(); final Runnable singleproducer = () ->{ try { for (int i = 0; i < 5; i++) { System.out.println("Produced: " + i); que.put(i); } } catch (Exception e) { e.printStackTrace(); } }; final Runnable singleConsumer = () ->{ while(true) { try { System.out.println("Consumer"+que.take()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; new Thread(singleproducer).start(); new Thread(singleConsumer).start(); } } 选项将路径设置为包含sphinx-apidoc--templatedirmodule.rst_t文件的目录。可以从package.rst_t中的相应文件创建文件。

然后,用toc.rst_t替换

site-packages/sphinx/templates/apidoc

使用

package.rst_t

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

答案 1 :(得分:0)

一种可能的解决方案是使用JS来查找&amp;在页面加载后替换“module”一词:

使用以下内容创建文件Private Sub Form_BeforeUpdate(Cancel As Integer) Me.[ColumnName] = Nz(Me.ColumnName, vbNullString) 'Making sure your column doesn't get null value passed End Sub

source/_templates/layout.html

确保{% extends "!layout.html" %} {% block extrahead %} <script type="text/javascript"> window.onload = function() { document.body.innerHTML = document.body.innerHTML.replace(/ module/g, ''); } </script> {% endblock %} 设置了conf.py,然后Sphinx会将脚本附加到所有文档页面的templates_path = ['_templates'],瞧!