Update conf.py

pull/1/head
潘鸿洋 2022-12-21 17:18:23 +08:00 committed by GitHub
parent ddcae6a6c0
commit 3e323e52be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 65 deletions

View File

@ -164,68 +164,3 @@ texinfo_documents = [
author, 'percy', 'One line description of project.', author, 'percy', 'One line description of project.',
'Miscellaneous'), 'Miscellaneous'),
] ]
# -- Options for breathe --------------------------------------------------
import subprocess, os
read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True'
if read_the_docs_build:
subprocess.call('doxygen Doxyfile', shell = True)
breathe_projects = {"percy": "xml"}
breathe_default_project = "percy"
# -- Custom directives --------------------------------------------------
from docutils import nodes
from docutils.parsers.rst import Directive
from sphinx import addnodes
def extract_brief(tree, name):
node = tree.findtext("./compounddef/sectiondef/memberdef/[name='%s']/briefdescription/para" % name)
return node.strip() if node else "no brief description"
class DocBriefDirective(Directive):
has_content = True
def run(self):
tree = self.state.document.settings.env.app.doxyxml
return [nodes.line(text = extract_brief(tree, self.content[0].strip()))]
class DocBriefTableDirective(Directive):
has_content = True
def run(self):
tree = self.state.document.settings.env.app.doxyxml
table = nodes.table()
tgroup = nodes.tgroup(cols = 2)
tgroup += nodes.colspec(colwidth = 50)
tgroup += nodes.colspec(colwidth = 50)
# header
tgroup += nodes.thead('', nodes.row('', *[nodes.entry('', nodes.line(text = c)) for c in ["Function", "Description"]]))
# rows
tbody = nodes.tbody()
for c in self.content:
name = c.strip()
query = name.replace("&", " &")
for elem in tree.findall("./compounddef/sectiondef/memberdef/[name='%s']" % query):
args = ', '.join(e.text for e in elem.findall("./param/declname"))
ref = addnodes.pending_xref('', refdomain = 'cpp', refexplicit = False, reftype = 'func', reftarget = 'percy::' + name)
ref += nodes.literal(text = '%s(%s)' % (name, args))
reft = nodes.paragraph()
reft.extend([ref])
func = nodes.entry('', reft)
desc = nodes.entry('', nodes.line(text = elem.findtext("./briefdescription/para")))
tbody += nodes.row('', func, desc)
tgroup += tbody
table += tgroup
return [table]
def setup(app):
import xml.etree.ElementTree as ET
app.doxyxml = ET.parse("xml/namespacepercy.xml")
app.add_directive('doc_brief', DocBriefDirective)
app.add_directive('doc_brief_table', DocBriefTableDirective)