Skip to content

Commit 63c42d6

Browse files
authored
Merge pull request #80 from Tieqiong/docstrings
Update docstrings and format api
2 parents dd2b9e5 + c8242af commit 63c42d6

33 files changed

+1620
-811
lines changed

doc/source/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
"m2r",
4949
]
5050

51+
autodoc_member_order = "groupwise"
52+
5153
# Add any paths that contain templates here, relative to this directory.
5254
templates_path = ["_templates"]
5355

@@ -121,6 +123,7 @@
121123
nitpick_ignore = [
122124
("py:class", "array_like"),
123125
("py:class", "Parser"),
126+
("py:class", "CifFile"),
124127
]
125128

126129
# -- Options for HTML output ----------------------------------------------

src/diffpy/Structure.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
#
1414
##############################################################################
1515

16-
"""
17-
Support import of old camel-case module names with DeprecationWarning.
16+
"""Support import of old camel-case module names with `DeprecationWarning`.
1817
1918
The imported camel-case modules are aliases for the current module
20-
instances. Their `__name__` attributes are thus all in lower-case.
19+
instances. Their `__name__` attributes are thus all in lower-case.
2120
21+
Warning
22+
-------
2223
This module is deprecated and will be removed in the future.
2324
"""
2425

src/diffpy/structure/__init__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,25 @@
1414
##############################################################################
1515

1616
"""
17-
Classes related to the structure of materials.
17+
Crystal structure container and parsers for structure formats.
1818
19-
Classes:
20-
Atom
19+
Classes related to the structure of materials:
20+
* Atom
21+
* Lattice
22+
* Structure
23+
* PDFFitStructure
2124
22-
Lattice
25+
Other classes:
26+
* SpaceGroup
27+
* SymOp
28+
* ExpandAsymmetricUnit
29+
* GeneratorSite
30+
* SymmetryConstraints
2331
24-
Structure
25-
26-
PDFFitStructure
2732
Exceptions:
28-
StructureFormatError
29-
30-
LatticeError
31-
32-
SymmetryError
33+
* StructureFormatError
34+
* LatticeError
35+
* SymmetryError
3336
"""
3437

3538
# Interface definitions ------------------------------------------------------
@@ -44,14 +47,11 @@
4447
# package version
4548
from diffpy.structure.version import __version__
4649

47-
"""Crystal structure container and parsers for structure formats."""
48-
4950
# top level routines
5051

5152

5253
def loadStructure(filename, fmt="auto", **kw):
53-
"""
54-
Load new structure object from the specified file.
54+
"""Load new structure object from the specified file.
5555
5656
Parameters
5757
----------

src/diffpy/structure/_legacy_importer.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,23 @@
1717
Support import of old camel-case module names with DeprecationWarning.
1818
1919
The imported camel-case modules are aliases for the current module
20-
instances. Their `__name__` attributes are thus all in lower-case.
20+
instances. Their `__name__` attributes are thus all in lower-case.
2121
22-
This module is deprecated and will be removed in the future.
22+
Note
23+
----
24+
this module must be only imported from `diffpy.Structure`.
2325
24-
NOTE: this module must be only imported from `diffpy.Structure`.
26+
Warning
27+
-------
28+
This module is deprecated and will be removed in the future.
2529
"""
2630

2731

2832
import importlib.abc
2933
import sys
3034
from warnings import warn
3135

32-
WMSG = "Module {!r} is deprecated. Use {!r} instead."
36+
WMSG = "Module {!r} is deprecated. Use {!r} instead."
3337

3438
# ----------------------------------------------------------------------------
3539

@@ -56,9 +60,7 @@ def find_spec(self, fullname, path=None, target=None):
5660

5761

5862
class MapRenamedStructureModule(importlib.abc.Loader):
59-
"""
60-
Loader for old camel-case module names.
61-
63+
"""Loader for old camel-case module names.
6264
Import the current module and alias it under the old name.
6365
"""
6466

src/diffpy/structure/apps/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
#
1414
##############################################################################
1515

16-
"""Script applications that use the diffpy.structure package.
16+
"""Script applications that use the `diffpy.structure` package.
1717
"""

src/diffpy/structure/apps/anyeye.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
##############################################################################
1515

1616
"""
17-
anyeye view structure file in atomeye
17+
Anyeye view structure file in atomeye.
1818
19-
Usage: anyeye [options] strufile
19+
Usage: ``anyeye [options] strufile``
2020
21-
Anyeye understands more structure formats than atomeye. It converts strufile
22-
to a temporary XCFG file which is opened in atomeye. Supported file formats:
23-
inputFormats
21+
Anyeye understands more `Structure` formats than atomeye. It converts `strufile`
22+
to a temporary XCFG file which is opened in atomeye. See supported file formats:
23+
``inputFormats``
2424
2525
Options:
2626
-f, --formula
27-
Override chemical formula in strufile. The formula defines
28-
elements in the same order as in strufile, e.g., Na4Cl4.
27+
Override chemical formula in `strufile`. The formula defines
28+
elements in the same order as in `strufile`, e.g., ``Na4Cl4``.
2929
3030
-w, --watch
3131
Watch input file for changes.
@@ -36,7 +36,7 @@
3636
3737
--formats=FORMATS
3838
Comma-separated list of file formats that are understood
39-
by the VIEWER, by default "xcfg,pdb". Files of other
39+
by the VIEWER, by default ``"xcfg,pdb"``. Files of other
4040
formats will be converted to the first listed format.
4141
4242
-h, --help
@@ -65,7 +65,7 @@
6565

6666

6767
def usage(style=None):
68-
"""show usage info, for style=="brief" show only first 2 lines"""
68+
"""Show usage info, for ``style=="brief"`` show only first 2 lines."""
6969
import os.path
7070

7171
myname = os.path.basename(sys.argv[0])
@@ -91,7 +91,17 @@ def version():
9191
def loadStructureFile(filename, format="auto"):
9292
"""Load structure from specified file.
9393
94-
Return a tuple of (Structure, fileformat).
94+
Parameters
95+
----------
96+
filename : str
97+
Path to the structure file.
98+
format : str, Optional
99+
File format, by default "auto".
100+
101+
Returns
102+
-------
103+
tuple
104+
A tuple of (Structure, fileformat).
95105
"""
96106
from diffpy.structure import Structure
97107

@@ -165,7 +175,7 @@ def cleanUp(pd):
165175

166176

167177
def parseFormula(formula):
168-
"""parse chemical formula and return a list of elements"""
178+
"""Parse chemical formula and return a list of elements"""
169179
# remove all blanks
170180
formula = re.sub(r"\s", "", formula)
171181
if not re.match("^[A-Z]", formula):

src/diffpy/structure/apps/transtru.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,26 @@
1313
#
1414
##############################################################################
1515

16-
"""transtru translate structure file to different format
17-
Usage: transtru INFMT..OUTFMT strufile
16+
"""Translate structure file to different format.
1817
19-
translates structure file strufile from INFMT to OUTFMT format and prints it
20-
to the screen. Use "-" as strufile to read from standard input. To save the
18+
Usage: ``transtru INFMT..OUTFMT strufile``
19+
20+
Translates structure file strufile from `INFMT` to `OUTFMT` format and prints it
21+
to the screen. Use "-" as `strufile` to read from standard input. To save the
2122
translated file, use
2223
23-
transtru INFMT..OUTFMT strufile > strufile.out
24+
``transtru INFMT..OUTFMT strufile > strufile.out``
2425
2526
Supported input and output structure formats are
26-
INFMT: inputFormats
27-
OUTFMT: outputFormats
27+
* `INFMT`: ``inputFormats``
28+
* `OUTFMT`: ``outputFormats``
2829
2930
Options:
30-
-h, --help display this message
31-
-V, --version show script version
31+
-h, --help
32+
Display this message.
33+
34+
-V, --version
35+
Show script version.
3236
"""
3337

3438
from __future__ import print_function
@@ -40,7 +44,7 @@
4044

4145

4246
def usage(style=None):
43-
"""show usage info, for style=="brief" show only first 2 lines"""
47+
"""Show usage info, for ``style=="brief"`` show only first 2 lines."""
4448
import os.path
4549

4650
myname = os.path.basename(sys.argv[0])

0 commit comments

Comments
 (0)