Skip to content

Commit 6078af3

Browse files
authored
πŸ“ Update docs for 1.8.5 (#301)
2 parents 251fdb4 + 63e6443 commit 6078af3

File tree

13 files changed

+718
-191
lines changed

13 files changed

+718
-191
lines changed

β€Žbin/buildβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
CPAC_DIRECTORY=$(python -c "import os, CPAC; print(os.path.abspath(os.path.dirname(CPAC.__file__)))")
55
ln ${CPAC_DIRECTORY}/resources/configs/1.7-1.8-nesting-mappings.yml docs/_sources/references/1.7-1.8-nesting-mappings.yml || true
66
ln ${CPAC_DIRECTORY}/resources/configs/1.7-1.8-deprecations.yml docs/_sources/references/1.7-1.8-deprecations.yml || true
7-
ln ${CPAC_DIRECTORY}/resources/configs/default_pipeline.yml docs/_sources/references/default_pipeline.yml || true
7+
ln ${CPAC_DIRECTORY}/resources/configs/pipeline_config_default.yml docs/_sources/references/default_pipeline.yml || true
88

99
# build docs
1010
sphinx-build -b html docs/_sources docs/$1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.. warning::
2+
23
Prior to v1.8.5, C-PAC erroneously used the ``DwellTime`` value from the fieldmap metadata instead of the appropriate ``EffectiveEchoSpacing`` value from the BOLD metadata.

β€Ždocs/_sources/conf.pyβ€Ž

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import m2r
1615
import os
1716
import re
18-
import semver
1917
import sys
2018

21-
from CPAC import __version__
2219
from dateutil import parser as dparser
20+
from CPAC import __version__
21+
from CPAC.utils.monitoring import custom_logging
2322
from github import Github
2423
from github.GithubException import RateLimitExceededException, \
2524
UnknownObjectException
25+
import m2r
26+
import semver
2627
from pybtex.plugin import register_plugin
2728

2829
sys.path.append(os.path.dirname(__file__))
@@ -144,11 +145,11 @@ def yaml_to_rst(path):
144145
'sphinx.ext.ifconfig',
145146
'sphinx.ext.intersphinx',
146147
'sphinx.ext.mathjax',
148+
'sphinx.ext.napoleon',
147149
'sphinx.ext.viewcode',
148150
'sphinxcontrib.programoutput',
149151
'exec',
150-
'nbsphinx',
151-
'numpydoc']
152+
'nbsphinx']
152153

153154
bibtex_bibfiles = [f'references/{bib}' for bib in os.listdir('references') if
154155
bib.endswith('.bib')]
@@ -571,14 +572,60 @@ def _unireplace(release_note, unireplace):
571572
) if len(gh_tags) >= 5 else ""
572573

573574

574-
def setup(app):
575-
from CPAC.utils.monitoring import custom_logging
575+
def autodoc_process_docstring(app, what, name, obj, options, lines) -> None:
576+
"""Modify docstrings before parsing RST"""
577+
# pylint: disable=too-many-arguments,unused-argument
578+
initialize_factory()
579+
if what == "function":
580+
format_node_block_docstrings(lines)
581+
576582

577-
# initilaize class to make factory functions available to Sphinx
578-
ml = custom_logging.MockLogger('test', 'test.log', 0, '/tmp')
583+
def format_node_block_docstrings(lines: list) -> None:
584+
"""Format Node Block docstring dictionaries as Python code blocks
585+
586+
Parameters
587+
----------
588+
lines : list
589+
modified in-place
590+
"""
591+
indent = 0
592+
insert_at = None
593+
insert_herald = True
594+
nevermore = False
595+
for i, line in enumerate(lines):
596+
if re.match(r"\s*{['\"]outputs['\"]:", line):
597+
nevermore = True
598+
if nevermore and not line.strip():
599+
indent = 0
600+
if line.lstrip().startswith("Node Block:"):
601+
indent = 3
602+
insert_at = i + 1
603+
insert_herald = False
604+
else:
605+
if indent == 0 and re.match(r"\s*{['\"]name['\"]:", line):
606+
insert_at = i
607+
indent = 3
608+
lines[i] = f'{" " * indent}{line}'
609+
if insert_at is not None:
610+
lines.insert(insert_at, '')
611+
lines.insert(insert_at, ".. code-block:: Python")
612+
if insert_herald:
613+
lines.insert(insert_at, '')
614+
lines.insert(insert_at, "Node Block:")
615+
616+
617+
def initialize_factory() -> None:
618+
"""Initilaize class to make factory functions available to Sphinx"""
619+
mocklogger = custom_logging.MockLogger('test', 'test.log', 0, '/tmp')
579620
for method in [
580621
method for method in
581-
set(dir(ml)) - set(dir(custom_logging.MockLogger)) if
622+
set(dir(mocklogger)) - set(dir(custom_logging.MockLogger)) if
582623
method not in ['name', 'handlers']
583624
]:
584-
setattr(custom_logging.MockLogger, method, getattr(ml, method))
625+
setattr(custom_logging.MockLogger, method,
626+
getattr(mocklogger, method))
627+
628+
629+
def setup(app) -> None:
630+
"""Extend Sphinx"""
631+
app.connect('autodoc-process-docstring', autodoc_process_docstring)

β€Ždocs/_sources/developer/workflow_documentation.rstβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ How to write workflow code with proper documentation
1414
Proper workflow documentation will follow the general standards provided by numpy (https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt). Because workflow creation functions are themselves python functions, their parameters and what they return should be documented as such. Please refer to the `example.py <https://github.com/numpy/numpy/blob/master/doc/example.py>`_ provided by numpy for syntax.
1515

1616

17-
:doc:`Example of a documented workflow <../workflows/anat_preproc>`
17+
:doc:`Example of a documented workflow <workflows/anat_preproc>`
1818

1919

2020
**Notes section:**

β€Ždocs/_sources/developer/workflows/alff.rstβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ Amplitude of Low Frequency Fluctuations(ALFF) and fractional ALFF
33

44
.. automodule:: CPAC.alff
55
:members:
6+
7+
.. automodule:: CPAC.alff.alff
8+
:members:
9+
10+
.. automodule:: CPAC.alff.utils
11+
:members:

β€Ždocs/_sources/references/Exported Items.bibβ€Ž

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
Β (0)