19import lxml.etree
as ET
22from datetime
import date
24sys.path.insert(0, os.path.abspath(
'../Base/Python'))
39 'sphinx_markdown_tables',
49autodoc_mock_imports = [
55myst_enable_extensions = [
65myst_heading_anchors = 6
68myst_dmath_allow_labels =
True
71templates_path = [
'_templates']
76source_suffix = [
'.rst',
'.md']
83copyright = f
'{date.today().year}, Slicer Community'
84author =
'Slicer Community'
98exclude_patterns = [
'_build',
'Thumbs.db',
'.DS_Store',
'_moduledescriptions']
102if os.environ.get(
'EXCLUDE_API_REFERENCE',
False) ==
'True':
103 print(
"API reference is excluded from documentation.")
104 exclude_patterns.append(
'developer_guide/vtkTeem.rst')
105 exclude_patterns.append(
'developer_guide/vtkAddon.rst')
106 exclude_patterns.append(
'developer_guide/vtkITK.rst')
107 exclude_patterns.append(
'developer_guide/slicer.rst')
108 exclude_patterns.append(
'developer_guide/mrml.rst')
113 'title':
'Page Not Found',
115<h1>Page Not Found</h1>
116<p>Sorry, we couldn't find that page.</p>
117<p>Try using the search box or go to the homepage.</p>
122pygments_style =
'sphinx'
125todo_include_todos =
False
128rst_prolog = open(
'global.rst.in').read()
132html_logo =
'_static/images/3D-Slicer-Mark.png'
139html_theme =
'default'
145html_theme_options = {
147 'includehidden':
False,
153html_static_path = [
'_static']
164htmlhelp_basename =
'3DSlicerdoc'
191 (master_doc,
'3DSlicer.tex',
'3D Slicer Documentation',
192 'Slicer Community',
'manual'),
201 (master_doc,
'3Dslicer',
'3D Slicer Documentation',
212 (master_doc,
'3DSlicer',
'3D Slicer Documentation',
213 author,
'3DSlicer',
'One line description of project.',
221on_rtd = os.environ.get(
'READTHEDOCS',
None) ==
'True'
224 import sphinx_rtd_theme
225 html_theme =
'sphinx_rtd_theme'
226 html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
249docsfolder = os.path.dirname(__file__)
253 os.path.join(docsfolder,
"../Modules/CLI"),
254 os.path.join(docsfolder,
"_extracli"),
261 'TestGridTransformRegistration.xml',
262 'DiffusionTensorTest.xml',
266outpath = os.path.join(docsfolder,
"_moduledescriptions")
267os.makedirs(outpath, exist_ok=
True)
268with open(os.path.join(outpath,
'_readme_.txt'),
'w')
as descriptionfile:
269 descriptionfile.write(
"Content of this folder is automatically generated by Docs/conf.py from CLI module descriptor XML files\n")
270 descriptionfile.write(
"during documentation build. The folder can be deleted because it is automatically regenerated when needed.")
274 """Helper function to create markdown file from CLI module description XML file using XSLT"""
275 xsltpath = os.path.join(docsfolder, xslt)
276 transform = ET.XSLT(ET.parse(xsltpath))
277 content = str(transform(dom))
278 with open(os.path.join(outpath, os.path.splitext(name)[0] + suffix +
'.md'),
'w', encoding=
'utf8')
as outfile:
279 outfile.write(content)
282for inputpath
in inputpaths:
283 for root, dirs, files
in os.walk(inputpath):
285 if name
in excludenames:
287 if name.endswith(
".xml"):
288 print(f
"Generating CLI module documentation from {name}")
289 dom = ET.parse(os.path.join(root, name))
290 _generatemd(dom, docsfolder, outpath,
"cli_module_overview_to_md.xsl",
"Overview")
291 _generatemd(dom, docsfolder, outpath,
"cli_module_parameters_to_md.xsl",
"Parameters")
_generatemd(dom, docsfolder, outpath, xslt, suffix)