Skip to content

Commit 5002985

Browse files
authored
📝 Document FCP-INDI/C-PAC#1919 (👔 Use filtered movement parameters to calculate FD-J) (#306)
2 parents e125342 + ce117c0 commit 5002985

File tree

7 files changed

+364
-4
lines changed

7 files changed

+364
-4
lines changed

docs/_sources/autodoc_nodeblock.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from typing import TYPE_CHECKING, Any
2+
from CPAC.pipeline.nodeblock import NodeBlockFunction
3+
from docutils.statemachine import StringList
4+
from sphinx.ext.autodoc import Documenter, FunctionDocumenter, bool_option
5+
6+
7+
class NBFMixin(Documenter):
8+
def add_directive_header(self, sig: str) -> None:
9+
"""Prepend "NodeBlockFunction" to the name & add the directive
10+
header and options to the generated content."""
11+
domain = getattr(self, 'domain', 'py')
12+
directive = getattr(self, 'directivetype', self.objtype)
13+
name = self.format_name()
14+
sourcename = self.get_sourcename()
15+
16+
# Prepend NodeBlockFunction pseudoheader
17+
self.add_line(f'*NodeBlockFunction*: **{self.object.name}**',
18+
sourcename)
19+
self.add_line('', sourcename)
20+
# one signature per line, indented by column
21+
prefix = f'.. {domain}:{directive}:: '
22+
for i, sig_line in enumerate(sig.split("\n")):
23+
self.add_line(f'{prefix}{name}{sig_line}',
24+
sourcename)
25+
if i == 0:
26+
prefix = " " * len(prefix)
27+
28+
if self.options.no_index or self.options.noindex:
29+
self.add_line(' :no-index:', sourcename)
30+
if self.objpath:
31+
# Be explicit about the module, this is necessary since .. class::
32+
# etc. don't support a prepended module name
33+
self.add_line(' :module: %s' % self.modname, sourcename)
34+
35+
36+
class NodeBlockFunctionDocumenter(NBFMixin, FunctionDocumenter):
37+
"""Sphinx Documenter for NodeBlockFunction"""
38+
objtype = 'NodeBlockFunction'
39+
directivetype = FunctionDocumenter.objtype
40+
priority = 10 + FunctionDocumenter.priority
41+
option_spec = dict(FunctionDocumenter.option_spec)
42+
option_spec['hex'] = bool_option
43+
44+
@classmethod
45+
def can_document_member(cls, member: Any, membername: str, isattr: bool,
46+
parent: Any) -> bool:
47+
"""Determine if a member is a NodeBlockFunction"""
48+
return isinstance(member, NodeBlockFunction)
49+
50+
def add_content(self,
51+
more_content: StringList | None
52+
) -> None:
53+
54+
super().add_content(more_content)
55+
56+
source_name = self.get_sourcename()
57+
# nbf_object: NodeBlockFunction = self.object
58+
self.add_line('', source_name)
59+
60+
61+
62+
def setup(app: 'Sphinx') -> dict[str, Any]:
63+
app.setup_extension('sphinx.ext.autodoc') # Require autodoc extension
64+
app.add_autodocumenter(NodeBlockFunctionDocumenter)
65+
return {
66+
'version': '0.1',
67+
'parallel_read_safe': True,
68+
'parallel_write_safe': True,
69+
}

docs/_sources/conf.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
import os
1616
import re
1717
import sys
18+
from typing import Any
1819

1920
from dateutil import parser as dparser
2021
from CPAC import __version__
22+
from CPAC.pipeline.nodeblock import NodeBlockFunction
2123
from CPAC.utils.monitoring import custom_logging
2224
from github import Github
2325
from github.GithubException import RateLimitExceededException, \
2426
UnknownObjectException
2527
import m2r
28+
from nipype import __version__ as _nipype_version
2629
import semver
2730
from pybtex.plugin import register_plugin
2831

@@ -36,6 +39,18 @@
3639
# https://python-semver.readthedocs.io/en/latest/usage.html
3740

3841

42+
# class DocumentNodeBlockFunction(FunctionDocumenter):
43+
# """Document Node Block Functions"""
44+
# objtype = 'Function'
45+
# priority = 10
46+
47+
# @classmethod
48+
# def can_document_member(cls, member: Any, membername: str, isattr: bool,
49+
# parent: Any) -> bool:
50+
# """Determine if a member is a NodeBlockFunction"""
51+
# return isinstance(member, NodeBlockFunction)
52+
53+
3954
def coerce(version):
4055
"""
4156
Convert an incomplete version string into a semver-compatible VersionInfo
@@ -148,13 +163,20 @@ def yaml_to_rst(path):
148163
'sphinx.ext.napoleon',
149164
'sphinx.ext.viewcode',
150165
'sphinxcontrib.programoutput',
166+
'autodoc_nodeblock',
151167
'exec',
152168
'nbsphinx']
153169

154170
bibtex_bibfiles = [f'references/{bib}' for bib in os.listdir('references') if
155171
bib.endswith('.bib')]
156172
bibtex_default_style = 'cpac_docs_style'
157173

174+
intersphinx_mapping = {
175+
'nipype': (f'https://nipype.readthedocs.io/en/{_nipype_version}/', None),
176+
'python': ('https://docs.python.org/3', None)}
177+
178+
napoleon_preprocess_types = True
179+
158180
# Add any paths that contain templates here, relative to this directory.
159181
templates_path = ['_templates']
160182

@@ -629,4 +651,5 @@ def initialize_factory() -> None:
629651

630652
def setup(app) -> None:
631653
"""Extend Sphinx"""
654+
# modify docstrings before parsing RST
632655
app.connect('autodoc-process-docstring', autodoc_process_docstring)

docs/_sources/developer/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Contents:
2424
workflow_documentation
2525
workflows/index
2626
xcpqc
27+
utils
2728
testing
2829
continuous_integration
2930
deprecating
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
Pipeline Development
22
====================
33

4-
.. include:: /developer/schema.rst
4+
.. include:: /developer/schema.rst
5+
6+
Pipeline Utilities
7+
^^^^^^^^^^^^^^^^^^
8+
9+
.. automodule:: CPAC.pipeline.utils
10+
:members:
11+
:undoc-members:

docs/_sources/developer/utils.rst

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
Utilities
2+
=========
3+
4+
BIDS Utilities
5+
^^^^^^^^^^^^^^
6+
7+
.. automodule:: CPAC.utils.bids_utils
8+
:members:
9+
:undoc-members:
10+
11+
BIDS Data Configuration
12+
^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
.. automodule:: CPAC.utils.bids_data_config
15+
:members:
16+
:undoc-members:
17+
18+
Configuration
19+
^^^^^^^^^^^^^
20+
21+
.. automodule:: CPAC.utils.configuration
22+
:members:
23+
:undoc-members:
24+
25+
Create FMRIB's Local Analysis of Mixed Effects (FLAME) Model Files
26+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
28+
.. automodule:: CPAC.utils.create_flame_model_files
29+
:members:
30+
:undoc-members:
31+
32+
Create FSL FLAME Preset
33+
^^^^^^^^^^^^^^^^^^^^^^^
34+
35+
.. automodule:: CPAC.utils.create_fsl_flame_preset
36+
:members:
37+
:undoc-members:
38+
39+
Create FSL create_fsl_model
40+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
41+
42+
.. automodule:: CPAC.utils.create_fsl_model
43+
:members:
44+
:undoc-members:
45+
46+
Create Group Analysis Info Files
47+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48+
49+
.. automodule:: CPAC.utils.create_group_analysis_info_files
50+
:members:
51+
:undoc-members:
52+
53+
Datasource
54+
^^^^^^^^^^
55+
56+
.. automodule:: CPAC.utils.datasource
57+
:members:
58+
:undoc-members:
59+
60+
Datatypes
61+
^^^^^^^^^
62+
63+
.. automodule:: CPAC.utils.datatypes
64+
:members:
65+
:undoc-members:
66+
67+
Documentation
68+
^^^^^^^^^^^^^
69+
70+
.. automodule:: CPAC.utils.docs
71+
:members:
72+
:undoc-members:
73+
74+
Extract Data
75+
^^^^^^^^^^^^
76+
77+
.. automodule:: CPAC.utils.extract_data
78+
:members:
79+
:undoc-members:
80+
81+
Extract Data (Multiscan)
82+
^^^^^^^^^^^^^^^^^^^^^^^^
83+
84+
.. automodule:: CPAC.utils.extract_data_multiscan
85+
:members:
86+
:undoc-members:
87+
88+
Extract Parameters
89+
^^^^^^^^^^^^^^^^^^
90+
91+
.. automodule:: CPAC.utils.extract_parameters
92+
:members:
93+
:undoc-members:
94+
95+
Google Analytics
96+
^^^^^^^^^^^^^^^^
97+
98+
.. automodule:: CPAC.utils.ga
99+
:members:
100+
:undoc-members:
101+
102+
Interfaces
103+
^^^^^^^^^^
104+
105+
Function Interfaces
106+
-------------------
107+
108+
.. automodule:: CPAC.utils.interfaces.function
109+
:members:
110+
:undoc-members:
111+
112+
Tests
113+
-----
114+
115+
.. automodule:: CPAC.utils.interfaces.tests
116+
:members:
117+
:undoc-members:
118+
119+
Miscellaneous
120+
^^^^^^^^^^^^^
121+
122+
.. automodule:: CPAC.utils.misc
123+
:members:
124+
:undoc-members:
125+
126+
Monitoring
127+
^^^^^^^^^^
128+
129+
.. automodule:: CPAC.utils.monitoring
130+
:members:
131+
:undoc-members:
132+
133+
NeuroData's MRI to Graphs (NDMG | m2g) Utilities
134+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135+
136+
.. automodule:: CPAC.utils.ndmg_utils
137+
:members:
138+
:undoc-members:
139+
140+
Neuroimaging Informatics Technology Initiative (NIfTI) Utilities
141+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
142+
143+
.. automodule:: CPAC.utils.nifti_utils
144+
:members:
145+
:undoc-members:
146+
147+
Outputs
148+
^^^^^^^
149+
150+
.. automodule:: CPAC.utils.outputs
151+
:members:
152+
:undoc-members:
153+
154+
pytest
155+
^^^^^^
156+
157+
.. automodule:: CPAC.utils.pytest
158+
:members:
159+
:undoc-members:
160+
161+
Serialization
162+
^^^^^^^^^^^^^
163+
164+
.. automodule:: CPAC.utils.serialization
165+
:members:
166+
:undoc-members:
167+
168+
Strategy
169+
^^^^^^^^
170+
171+
.. automodule:: CPAC.utils.strategy
172+
:members:
173+
:undoc-members:
174+
175+
Symlinks
176+
^^^^^^^^
177+
178+
.. automodule:: CPAC.utils.symlinks
179+
:members:
180+
:undoc-members:
181+
182+
Test Initialization
183+
^^^^^^^^^^^^^^^^^^^
184+
185+
.. automodule:: CPAC.utils.test_init
186+
:members:
187+
:undoc-members:
188+
189+
Test Mocks
190+
^^^^^^^^^^
191+
192+
.. automodule:: CPAC.utils.test_mocks
193+
:members:
194+
:undoc-members:
195+
196+
Test Resources
197+
^^^^^^^^^^^^^^
198+
199+
.. automodule:: CPAC.utils.test_resources
200+
:members:
201+
:undoc-members:
202+
203+
Tests
204+
^^^^^
205+
206+
.. automodule:: CPAC.utils.tests
207+
:members:
208+
:undoc-members:
209+
210+
The Trimmer
211+
^^^^^^^^^^^
212+
213+
.. automodule:: CPAC.utils.trimmer
214+
:members:
215+
:undoc-members:
216+
217+
Typing
218+
^^^^^^
219+
220+
.. automodule:: CPAC.utils.typing
221+
:members:
222+
:undoc-members:
223+
224+
Utilities
225+
^^^^^^^^^
226+
227+
.. automodule:: CPAC.utils.utils
228+
:members:
229+
:undoc-members:
230+
231+
Versioning
232+
^^^^^^^^^^
233+
.. automodule:: CPAC.utils.versioning
234+
:members:
235+
:undoc-members:

0 commit comments

Comments
 (0)