我开发了一个扩展,将(我的特殊(表内容添加到我的Sphinx文档中(请参阅https://github.com/procitec/sphinxcontrib-rst-table)
我使用了https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html.这很好用。表格和所有内容均正确显示
但是:扩展将所有表添加到其"中;自定义";索引,但我想将生成的表添加到正常的";表的列表";(例如,列出了所有ReST表(
我怎么能两者都有?
我的自定义索引条目以及";表";列在";表的列表";文件?
以下是生成自定义索引项的代码:
class TableIndex(Index):
"""A custom index that creates an table matrix."""
name = "tbl"
localname = "Table Index"
shortname = "Table"
def generate(self, docnames=None):
content = defaultdict(list)
# sort the list of tables in alphabetical order
tables = self.domain.get_objects()
tables = sorted(tables, key=lambda table: table[0])
# generate the expected output, shown below, from the above using the
# first letter of the recipe as a key to group thing
#
# name, subtype, docname, anchor, extra, qualifier, description
for _name, dispname, typ, docname, anchor, _priority in tables:
content[dispname[0].lower()].append((dispname, 0, docname, anchor, docname, "", typ))
# convert the dict to the sorted list of tuples expected
content = sorted(content.items())
return content, True
表本身被添加到类中
class TableDirective(ObjectDescription):
作为运行中的方法
node_table = nodes.table(classes=classes, ids=ids)
在向表添加标题(title(后,它按预期工作。指令中提供了标题,但扩展中未正确解析。