19 import lxml.etree
as ET
23 sys.path.insert(0, os.path.abspath(
'../Base/Python'))
24 sys.path.append(os.path.abspath(
"./_sphinxext"))
39 'sphinx_markdown_tables',
43 myst_enable_extensions = [
50 myst_heading_anchors = 6
53 templates_path = [
'_templates']
58 source_suffix = [
'.rst',
'.md']
65 copyright =
'2020, Slicer Community' 66 author =
'Slicer Community' 87 exclude_patterns = [
'_build',
'Thumbs.db',
'.DS_Store',
'_moduledescriptions']
91 if os.environ.get(
'EXCLUDE_API_REFERENCE',
False) ==
'True':
92 print(
"API reference is excluded from documentation.")
93 exclude_patterns.append(
'developer_guide/vtkTeem.rst')
94 exclude_patterns.append(
'developer_guide/vtkAddon.rst')
95 exclude_patterns.append(
'developer_guide/vtkITK.rst')
96 exclude_patterns.append(
'developer_guide/slicer.rst')
97 exclude_patterns.append(
'developer_guide/mrml.rst')
102 'title':
'Page Not Found',
104 <h1>Page Not Found</h1> 105 <p>Sorry, we couldn't find that page.</p> 106 <p>Try using the search box or go to the homepage.</p> 111 pygments_style =
'sphinx' 114 todo_include_todos =
False 117 rst_prolog = open(
'global.rst.in').read()
121 html_logo =
'_static/images/3D-Slicer-Mark.png' 128 html_theme =
'default' 134 html_theme_options = {
136 'includehidden':
False,
142 html_static_path = [
'_static']
153 htmlhelp_basename =
'3DSlicerdoc' 180 (master_doc,
'3DSlicer.tex',
'3D Slicer Documentation',
181 'Slicer Community',
'manual'),
190 (master_doc,
'3Dslicer',
'3D Slicer Documentation',
200 texinfo_documents = [
201 (master_doc,
'3DSlicer',
'3D Slicer Documentation',
202 author,
'3DSlicer',
'One line description of project.',
210 on_rtd = os.environ.get(
'READTHEDOCS',
None) ==
'True' 213 import sphinx_rtd_theme
214 html_theme =
'sphinx_rtd_theme' 215 html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
238 docsfolder = os.path.dirname(__file__)
242 os.path.join(docsfolder,
"../Modules/CLI"),
243 os.path.join(docsfolder,
"_extracli"),
250 'TestGridTransformRegistration.xml',
251 'DiffusionTensorTest.xml',
255 outpath = os.path.join(docsfolder,
"_moduledescriptions")
256 os.makedirs(outpath, exist_ok=
True)
257 with open(os.path.join(outpath,
'_readme_.txt'),
'w')
as descriptionfile:
258 descriptionfile.write(
"Content of this folder is automatically generated by Docs/conf.py from CLI module descriptor XML files\n")
259 descriptionfile.write(
"during documentation build. The folder can be deleted because it is automatically regenerated when needed.")
262 def _generatemd(dom, docsfolder, outpath, xslt, suffix):
263 """Helper function to create markdown file from CLI module description XML file using XSLT""" 264 xsltpath = os.path.join(docsfolder, xslt)
265 transform = ET.XSLT(ET.parse(xsltpath))
266 content = str(transform(dom))
267 with open(os.path.join(outpath, os.path.splitext(name)[0] + suffix +
'.md'),
'w', encoding=
'utf8')
as outfile:
268 outfile.write(content)
271 for inputpath
in inputpaths:
272 for root, dirs, files
in os.walk(inputpath):
274 if name
in excludenames:
276 if name.endswith(
".xml"):
277 print(f
"Generating CLI module documentation from {name}")
278 dom = ET.parse(os.path.join(root, name))
279 _generatemd(dom, docsfolder, outpath,
"cli_module_overview_to_md.xsl",
"Overview")
280 _generatemd(dom, docsfolder, outpath,
"cli_module_parameters_to_md.xsl",
"Parameters")