19import lxml.etree
as ET
22from datetime
import date
24sys.path.insert(0, os.path.abspath(
"../Base/Python"))
39 "sphinx_markdown_tables",
50autodoc_mock_imports = [
56myst_enable_extensions = [
66myst_heading_anchors = 6
69myst_dmath_allow_labels =
True
72templates_path = [
"_templates"]
77source_suffix = [
".rst",
".md"]
84copyright = f
"{date.today().year}, Slicer Community"
85author =
"Slicer Community"
99exclude_patterns = [
"_build",
"Thumbs.db",
".DS_Store",
"_moduledescriptions"]
103if 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>
123pygments_style =
"sphinx"
126todo_include_todos =
False
129rst_prolog = open(
"global.rst.in").read()
133html_logo =
"_static/images/3D-Slicer-Mark.png"
140html_theme =
"sphinx_rtd_theme"
146html_theme_options = {
148 "includehidden":
False,
154html_static_path = [
"_static"]
165htmlhelp_basename =
"3DSlicerdoc"
189 (master_doc,
"3DSlicer.tex",
"3D Slicer Documentation",
190 "Slicer Community",
"manual"),
199 (master_doc,
"3Dslicer",
"3D Slicer Documentation",
210 (master_doc,
"3DSlicer",
"3D Slicer Documentation",
211 author,
"3DSlicer",
"One line description of project.",
236docsfolder = os.path.dirname(__file__)
240 os.path.join(docsfolder,
"../Modules/CLI"),
241 os.path.join(docsfolder,
"_extracli"),
248 "TestGridTransformRegistration.xml",
249 "DiffusionTensorTest.xml",
253outpath = os.path.join(docsfolder,
"_moduledescriptions")
254os.makedirs(outpath, exist_ok=
True)
255with open(os.path.join(outpath,
"_readme_.txt"),
"w")
as descriptionfile:
256 descriptionfile.write(
"Content of this folder is automatically generated by Docs/conf.py from CLI module descriptor XML files\n")
257 descriptionfile.write(
"during documentation build. The folder can be deleted because it is automatically regenerated when needed.")
261 """Helper function to create markdown file from CLI module description XML file using XSLT"""
262 xsltpath = os.path.join(docsfolder, xslt)
263 transform = ET.XSLT(ET.parse(xsltpath))
264 content = str(transform(dom))
265 with open(os.path.join(outpath, os.path.splitext(name)[0] + suffix +
".md"),
"w", encoding=
"utf8")
as outfile:
266 outfile.write(content)
269for inputpath
in inputpaths:
270 for root, dirs, files
in os.walk(inputpath):
272 if name
in excludenames:
274 if name.endswith(
".xml"):
275 print(f
"Generating CLI module documentation from {name}")
276 dom = ET.parse(os.path.join(root, name))
277 _generatemd(dom, docsfolder, outpath,
"cli_module_overview_to_md.xsl",
"Overview")
278 _generatemd(dom, docsfolder, outpath,
"cli_module_parameters_to_md.xsl",
"Parameters")
_generatemd(dom, docsfolder, outpath, xslt, suffix)