enthought / scimath

Other
68 stars 16 forks source link

DOC: add docstrings to units #172

Closed homosapien-lcy closed 1 year ago

homosapien-lcy commented 1 year ago

As mentioned in issue #119 , it can help the users a great bit if we add doc string to the unit api. (Just realized there are so many different metric systems we have around the world...)

corranwebster commented 1 year ago

Quick comment here - docstrings are usually fed into tools like Sphinx for producing auto-generated documentation (under the covers they use reStrcuturedText). You should make sure that the docstrings will produce good output with these tools. In particular, I think the way that you have indented your lists will not parse correctly with Sphinx.

homosapien-lcy commented 1 year ago

Hi Corran, Mark: Could you give me an example of how to structure the docstring of this type, I cannot find sth of similar type?

homosapien-lcy commented 1 year ago

OK, I seem to figure it out from the top of other files... Have it updated

mdickinson commented 1 year ago

The best thing to do here would be to run a Sphinx build with warnings turned on and look at (a) the warnings output, and (b) the generated docs.

If we don't already have autodoc-based mechanisms to build the docs, the the first step might be to put those in place.

mdickinson commented 1 year ago

Looks like there is a python etstool.py docs command to build the documentation.

mdickinson commented 1 year ago

It would also make sense to have a GitHub Actions workflow that runs the documentation build on each PR, so that we can detect regressions quickly.

dpinte commented 1 year ago

Here is the output of the python etstools.py docs call. As you see there are some warning (related or not) to this PR. I can look at them and make sure they get fixed. That would be great!

$ python etstool.py docs
[EXECUTING] edm run -e scimath-test-3.6 -- sphinx-build -b html -d build/doctrees source build/html
Running Sphinx v3.5.4
making output directory... done
WARNING: favicon file 'et.ico' does not exist
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 12 source files that are out of date
updating environment: [new config] 12 added, 0 changed, 0 removed
reading sources... [100%] units/user_ref
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/convert.py:docstring of scimath.units.convert.convert:4: WARNING: Unexpected section title.

Parameters
----------
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/convert.py:docstring of scimath.units.convert.convert:13: WARNING: Unexpected section title.

Returns
-------
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/convert.py:docstring of scimath.units.convert.convert:18: WARNING: Unexpected section title.

Description
-----------
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/has_units.py:docstring of scimath.units.has_units.has_units:6: WARNING: Unexpected section title.

Parameters
----------
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/has_units.py:docstring of scimath.units.has_units.has_units:36: WARNING: Unexpected section title.

Description
-----------
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] units/user_ref
generating indices... genindex done
highlighting module code... [100%] scimath.units.unit_scalar
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 6 warnings.

The HTML pages are in build/html.
homosapien-lcy commented 1 year ago

Here is the output of the python etstools.py docs call. As you see there are some warning (related or not) to this PR. I can look at them and make sure they get fixed. That would be great!

$ python etstool.py docs
[EXECUTING] edm run -e scimath-test-3.6 -- sphinx-build -b html -d build/doctrees source build/html
Running Sphinx v3.5.4
making output directory... done
WARNING: favicon file 'et.ico' does not exist
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 12 source files that are out of date
updating environment: [new config] 12 added, 0 changed, 0 removed
reading sources... [100%] units/user_ref
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/convert.py:docstring of scimath.units.convert.convert:4: WARNING: Unexpected section title.

Parameters
----------
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/convert.py:docstring of scimath.units.convert.convert:13: WARNING: Unexpected section title.

Returns
-------
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/convert.py:docstring of scimath.units.convert.convert:18: WARNING: Unexpected section title.

Description
-----------
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/has_units.py:docstring of scimath.units.has_units.has_units:6: WARNING: Unexpected section title.

Parameters
----------
/Users/dpinte/.edm/envs/scimath-test-3.6/lib/python3.6/site-packages/scimath-5.1.0.dev419-py3.6-macosx-10.9-x86_64.egg/scimath/units/has_units.py:docstring of scimath.units.has_units.has_units:36: WARNING: Unexpected section title.

Description
-----------
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] units/user_ref
generating indices... genindex done
highlighting module code... [100%] scimath.units.unit_scalar
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 6 warnings.

The HTML pages are in build/html.

Got it, just changed