Skip to content

Commit d0e6363

Browse files
authored
Merge pull request #1163 from ZviBaratz/docs
Fixed documentation build error and warnings
2 parents 14faf88 + e86addb commit d0e6363

22 files changed

+77
-67
lines changed

.github/workflows/misc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
matrix:
2525
python-version: ["3.10"]
2626
install: ['pip']
27-
check: ['style', 'doc']
27+
check: ['style', 'doctest']
2828
pip-flags: ['']
2929
depends: ['REQUIREMENTS']
3030
env:

doc-requirements.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# Requirements for building docs
1+
# Auto-generated by tools/update_requirements.py
22
-r requirements.txt
3-
sphinx<3
3+
matplotlib >= 1.5.3
44
numpydoc
5+
sphinx ~= 5.3
56
texext
6-
matplotlib >=1.3.1
7+
tomli; python_version < "3.11"

doc/source/conf.py

+14-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
from pathlib import Path
2424
from runpy import run_path
2525

26-
import toml
26+
try:
27+
import tomllib
28+
except ImportError:
29+
import tomli as tomllib
2730

2831
# Check for external Sphinx extensions we depend on
2932
try:
@@ -52,14 +55,15 @@
5255
fobj.write(rel['long_description'])
5356

5457
# Load metadata from setup.cfg
55-
pyproject_dict = toml.load(Path("../../pyproject.toml"))
56-
metadata = pyproject_dict["project"]
58+
with open(Path("../../pyproject.toml"), 'rb') as fobj:
59+
pyproject = tomllib.load(fobj)
60+
authors = pyproject["project"]["authors"][0]
5761

5862
# Add any Sphinx extension module names here, as strings. They can be
5963
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
6064
extensions = ['sphinx.ext.autodoc',
6165
'sphinx.ext.doctest',
62-
#'sphinx.ext.intersphinx',
66+
'sphinx.ext.intersphinx',
6367
'sphinx.ext.todo',
6468
'sphinx.ext.mathjax',
6569
'sphinx.ext.inheritance_diagram',
@@ -69,9 +73,10 @@
6973
'matplotlib.sphinxext.plot_directive',
7074
]
7175

72-
# the following doesn't work with sphinx < 1.0, but will make a separate
73-
# sphinx-autogen run obsolete in the future
74-
#autosummary_generate = True
76+
# Autosummary always wants to use a `generated/` directory.
77+
# We generate with `make api-stamp`
78+
# This could change in the future
79+
autosummary_generate = False
7580

7681
# Add any paths that contain templates here, relative to this directory.
7782
templates_path = ['_templates']
@@ -87,9 +92,7 @@
8792

8893
# General information about the project.
8994
project = u'NiBabel'
90-
author_name = metadata["authors"][0]["name"]
91-
author_email = metadata["authors"][0]["email"]
92-
copyright = f"2006-2022, {author_name} <{author_email}>"
95+
copyright = f"2006-2022, {authors['name']} <{authors['email']}>"
9396

9497
# The version info for the project you're documenting, acts as replacement for
9598
# |version| and |release|, also used in various other places throughout the
@@ -269,7 +272,7 @@
269272

270273

271274
# Example configuration for intersphinx: refer to the Python standard library.
272-
intersphinx_mapping = {'https://docs.python.org/': None}
275+
intersphinx_mapping = {'https://docs.python.org/3/': None}
273276

274277
# Config of plot_directive
275278
plot_include_source = True

doc/source/devel/biaps/biap_0003.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ The base level header will usually also have image metadata fields giving
199199
information about the whole image. A field is an "image metadata field" if it
200200
is defined at the top level of the header. For example::
201201

202-
>>> hdr = dict(nipy_header_version='1.0',
203-
... Manufacturer="SIEMENS")
202+
>>> hdr = dict(nipy_header_version='1.0',
203+
... Manufacturer="SIEMENS")
204204

205205
All image metadata fields are optional.
206206

@@ -635,7 +635,7 @@ Use case
635635
^^^^^^^^
636636

637637
When doing motion correction on a 4D image, we calculate the required affine
638-
transformation from |--| say |--| the second image to the first image; the
638+
transformation from, say, the second image to the first image; the
639639
third image to the first image; etc. If there are N volumes in the 4D image,
640640
we would need to store N-1 affine transformations. If we have registered to
641641
the mean volume of the volume series instead of one of the volumes in the

doc/source/devel/biaps/biap_0004.rst

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ Improving access to varying meta data through the Nifti
221221

222222
Currently, when accessing varying meta data through the `get_meta` method
223223
you can only get one value at a time::
224+
224225
>>> echo_times = [nii.get_meta('EchoTime', (0, 0, 0, idx))
225226
for idx in xrange(data.shape[-1])]
226227

doc/source/devel/biaps/biap_0006.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ In NIfTI:
193193

194194
We saw above that the MGH format refers to a volume (in our sense) as a
195195
*frame*. ECAT has the same usage - a frame is a 3D volume. The fmristat
196-
software uses frame in the same sense |--| e.g. `line 32 of example.m
196+
software uses frame in the same sense, e.g., `line 32 of example.m
197197
<https://github.com/matthew-brett/fmristat/blob/master/fmristat/example.m#L32>`_.
198198

199199
Unfortunately DICOM appears to use "frame" to mean a 2D slice. For example,

doc/source/devel/devdiscuss.rst

+4
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ progress.
2222
spm_use
2323
modified_images
2424
data_pkg_design
25+
data_pkg_discuss
26+
data_pkg_uses
27+
scaling
28+
bv_formats

doc/source/devel/image_design.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:orphan:
2+
13
########################
24
The nibabel image object
35
########################

doc/source/installing_data.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:orphan:
2+
13
.. _installing-data:
24

35
Installing data packages

doc/source/old/ioimplementation.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. -*- mode: rst -*-
22
3+
:orphan:
4+
35
##################################################
46
Relationship between images and io implementations
57
##################################################

doc/tools/build_modref_templates.py

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def abort(error):
8383
r'\.info.*$',
8484
r'\.pkg_info.*$',
8585
r'\.py3k.*$',
86+
r'\._version.*$',
8687
]
8788
docwriter.write_api_docs(outdir)
8889
docwriter.write_index(outdir, 'index', relative_to=outdir)

nibabel/batteryrunners.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
To run checks only, and return problem report objects:
2222
23+
>>> from nibabel.batteryrunners import BatteryRunner, Report
2324
>>> def chk(obj, fix=False): # minimal check
2425
... return obj, Report()
2526
>>> btrun = BatteryRunner((chk,))

nibabel/ecat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def __init__(self, hdr, mlist, fileobj):
523523
there is one subheader for each frame in the ecat file
524524
525525
Parameters
526-
-----------
526+
----------
527527
hdr : EcatHeader
528528
ECAT main header
529529
mlist : array shape (N, 4)

nibabel/gifti/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
.. autosummary::
1414
:toctree: ../generated
1515
16-
giftiio
1716
gifti
1817
"""
1918

nibabel/processing.py

+2
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,13 @@ def conform(
327327
Using the default arguments, this function is meant to replicate most parts
328328
of FreeSurfer's ``mri_convert --conform`` command. Specifically, this
329329
function:
330+
330331
- Resamples data to ``output_shape``
331332
- Resamples voxel sizes to ``voxel_size``
332333
- Reorients to RAS (``mri_convert --conform`` reorients to LIA)
333334
334335
Unlike ``mri_convert --conform``, this command does not:
336+
335337
- Transform data to range [0, 255]
336338
- Cast to unsigned eight-bit integer
337339

nibabel/quaternions.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
they are applied on the left of the vector. For example:
2020
2121
>>> import numpy as np
22+
>>> from nibabel.quaternions import quat2mat
2223
>>> q = [0, 1, 0, 0] # 180 degree rotation around axis 0
2324
>>> M = quat2mat(q) # from this module
2425
>>> vec = np.array([1, 2, 3]).reshape((3,1)) # column vector

nibabel/spatialimages.py

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
example, the Analyze data format needs an ``image`` and a ``header``
9292
file type for storage:
9393
94+
>>> import numpy as np
9495
>>> import nibabel as nib
9596
>>> data = np.arange(24, dtype='f4').reshape((2,3,4))
9697
>>> img = nib.AnalyzeImage(data, np.eye(4))

nibabel/tmpdirs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class InTemporaryDirectory(TemporaryDirectory):
5252
"""Create, return, and change directory to a temporary directory
5353
5454
Notes
55-
------
55+
-----
5656
As its name suggests, the class temporarily changes the working
5757
directory of the Python process, and this is not thread-safe. We suggest
5858
using it only for tests.

pyproject.toml

+27-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ classifiers = [
2525
"Topic :: Scientific/Engineering",
2626
]
2727
# Version from versioneer
28-
# optional-dependencies from setup.cfg (using ConfigParser features)
29-
dynamic = ["version", "optional-dependencies"]
28+
dynamic = ["version"]
3029

3130
[project.urls]
3231
"Homepage" = "https://nipy.org/nibabel"
@@ -45,6 +44,32 @@ nib-trk2tck = "nibabel.cmdline.trk2tck:main"
4544
nib-roi = "nibabel.cmdline.roi:main"
4645
parrec2nii = "nibabel.cmdline.parrec2nii:main"
4746

47+
[project.optional-dependencies]
48+
dicom = ["pydicom >=1.0.0"]
49+
dicomfs = ["nibabel[dicom]", "pillow"]
50+
dev = ["gitpython", "twine"]
51+
doc = [
52+
"matplotlib >= 1.5.3",
53+
"numpydoc",
54+
"sphinx ~= 5.3",
55+
"texext",
56+
"tomli; python_version < \"3.11\"",
57+
]
58+
minc2 = ["h5py"]
59+
spm = ["scipy"]
60+
style = ["flake8"]
61+
test = [
62+
"coverage",
63+
"pytest !=5.3.4",
64+
"pytest-cov",
65+
"pytest-doctestplus",
66+
"pytest-httpserver",
67+
"pytest-xdist",
68+
]
69+
zstd = ["pyzstd >= 0.14.3"]
70+
doctest = ["nibabel[doc,test]"]
71+
all = ["nibabel[dicomfs,dev,doc,minc2,spm,style,test,zstd]"]
72+
4873
[tool.setuptools]
4974
platforms = ["OS Independent"]
5075
provides = ["nibabel", "nisext"]

setup.cfg

-40
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,3 @@
1-
[options.extras_require]
2-
dicom =
3-
pydicom >=1.0.0
4-
dicomfs =
5-
%(dicom)s
6-
pillow
7-
dev =
8-
gitpython
9-
twine
10-
doc =
11-
matplotlib >= 1.5.3
12-
numpydoc
13-
sphinx ~= 5.3
14-
texext
15-
toml
16-
minc2 =
17-
h5py
18-
spm =
19-
scipy
20-
style =
21-
flake8
22-
test =
23-
coverage
24-
pytest !=5.3.4
25-
pytest-cov
26-
pytest-doctestplus
27-
pytest-httpserver
28-
pytest-xdist
29-
zstd =
30-
pyzstd >= 0.14.3
31-
all =
32-
%(dicomfs)s
33-
%(dev)s
34-
%(doc)s
35-
%(minc2)s
36-
%(spm)s
37-
%(style)s
38-
%(test)s
39-
%(zstd)s
40-
411
[flake8]
422
max-line-length = 100
433
extend-ignore = E203,E266,E402,E731

tools/ci/check.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ export NIBABEL_DATA_DIR="$PWD/nibabel-data"
1616
if [ "${CHECK_TYPE}" == "style" ]; then
1717
# Run styles only on core nibabel code.
1818
flake8 nibabel
19-
elif [ "${CHECK_TYPE}" == "doc" ]; then
20-
cd doc
21-
make html && make doctest
19+
elif [ "${CHECK_TYPE}" == "doctest" ]; then
20+
make -C doc html && make -C doc doctest
2221
elif [ "${CHECK_TYPE}" == "test" ]; then
2322
# Change into an innocuous directory and find tests from installation
2423
mkdir for_testing

tools/update_requirements.py

+6
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
pyproject_toml = repo_root / "pyproject.toml"
1212
reqs = repo_root / "requirements.txt"
1313
min_reqs = repo_root / "min-requirements.txt"
14+
doc_reqs = repo_root / "doc-requirements.txt"
1415

1516
with open(pyproject_toml, 'rb') as fobj:
1617
config = tomli.load(fobj)
1718
requirements = config["project"]["dependencies"]
19+
doc_requirements = config["project"]["optional-dependencies"]["doc"]
1820

1921
script_name = Path(__file__).relative_to(repo_root)
2022

@@ -27,3 +29,7 @@
2729
# Write minimum requirements
2830
lines[1:-1] = [req.replace(">=", "==").replace("~=", "==") for req in requirements]
2931
min_reqs.write_text("\n".join(lines))
32+
33+
# Write documentation requirements
34+
lines[1:-1] = ["-r requirements.txt"] + doc_requirements
35+
doc_reqs.write_text("\n".join(lines))

0 commit comments

Comments
 (0)