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',
49 autodoc_mock_imports = [
55 myst_enable_extensions = [
62 myst_heading_anchors = 6
65 templates_path = [
'_templates']
70 source_suffix = [
'.rst',
'.md']
77 copyright =
'2020, Slicer Community' 78 author =
'Slicer Community' 99 exclude_patterns = [
'_build',
'Thumbs.db',
'.DS_Store',
'_moduledescriptions']
103 if os.environ.get(
'EXCLUDE_API_REFERENCE',
False) ==
'True':
104 print(
"API reference is excluded from documentation.")
105 exclude_patterns.append(
'developer_guide/vtkTeem.rst')
106 exclude_patterns.append(
'developer_guide/vtkAddon.rst')
107 exclude_patterns.append(
'developer_guide/vtkITK.rst')
108 exclude_patterns.append(
'developer_guide/slicer.rst')
109 exclude_patterns.append(
'developer_guide/mrml.rst')
114 'title':
'Page Not Found',
116 <h1>Page Not Found</h1> 117 <p>Sorry, we couldn't find that page.</p> 118 <p>Try using the search box or go to the homepage.</p> 123 pygments_style =
'sphinx' 126 todo_include_todos =
False 129 rst_prolog = open(
'global.rst.in').read()
133 html_logo =
'_static/images/3D-Slicer-Mark.png' 140 html_theme =
'default' 146 html_theme_options = {
148 'includehidden':
False,
154 html_static_path = [
'_static']
165 htmlhelp_basename =
'3DSlicerdoc' 192 (master_doc,
'3DSlicer.tex',
'3D Slicer Documentation',
193 'Slicer Community',
'manual'),
202 (master_doc,
'3Dslicer',
'3D Slicer Documentation',
212 texinfo_documents = [
213 (master_doc,
'3DSlicer',
'3D Slicer Documentation',
214 author,
'3DSlicer',
'One line description of project.',
222 on_rtd = os.environ.get(
'READTHEDOCS',
None) ==
'True' 225 import sphinx_rtd_theme
226 html_theme =
'sphinx_rtd_theme' 227 html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
250 docsfolder = os.path.dirname(__file__)
254 os.path.join(docsfolder,
"../Modules/CLI"),
255 os.path.join(docsfolder,
"_extracli"),
262 'TestGridTransformRegistration.xml',
263 'DiffusionTensorTest.xml',
267 outpath = os.path.join(docsfolder,
"_moduledescriptions")
268 os.makedirs(outpath, exist_ok=
True)
269 with open(os.path.join(outpath,
'_readme_.txt'),
'w')
as descriptionfile:
270 descriptionfile.write(
"Content of this folder is automatically generated by Docs/conf.py from CLI module descriptor XML files\n")
271 descriptionfile.write(
"during documentation build. The folder can be deleted because it is automatically regenerated when needed.")
274 def _generatemd(dom, docsfolder, outpath, xslt, suffix):
275 """Helper function to create markdown file from CLI module description XML file using XSLT""" 276 xsltpath = os.path.join(docsfolder, xslt)
277 transform = ET.XSLT(ET.parse(xsltpath))
278 content = str(transform(dom))
279 with open(os.path.join(outpath, os.path.splitext(name)[0] + suffix +
'.md'),
'w', encoding=
'utf8')
as outfile:
280 outfile.write(content)
283 for inputpath
in inputpaths:
284 for root, dirs, files
in os.walk(inputpath):
286 if name
in excludenames:
288 if name.endswith(
".xml"):
289 print(f
"Generating CLI module documentation from {name}")
290 dom = ET.parse(os.path.join(root, name))
291 _generatemd(dom, docsfolder, outpath,
"cli_module_overview_to_md.xsl",
"Overview")
292 _generatemd(dom, docsfolder, outpath,
"cli_module_parameters_to_md.xsl",
"Parameters")