diff --git a/.travis.yml b/.travis.yml index 844bf532..01246a06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ addons: before_script: - npm install -g jsdoc-to-markdown@4.0.1 - npm install -g google-closure-compiler@20190528.0.0 + - pip install pydoc-markdown script: - export CC=/usr/bin/gcc-6 diff --git a/generate/makedoc b/generate/makedoc index 91819d09..e74785c0 100755 --- a/generate/makedoc +++ b/generate/makedoc @@ -48,4 +48,9 @@ else echo "(Skipping generation of C documentation because file generate_c_docs does not exist.)" fi +echo "Generating Python documentation." +cd ../source/python || Fail "Error changing directory to ../source/python" +pydocmd simple astronomy+ > README.md || Fail "Error in pydocmd" +cd ../../generate || Fail "Error changing directory back" + exit 0 diff --git a/generate/template/astronomy.py b/generate/template/astronomy.py index c2cb2fb2..2f6fb793 100644 --- a/generate/template/astronomy.py +++ b/generate/template/astronomy.py @@ -174,6 +174,8 @@ def _TerrestrialTime(ut): return ut + _DeltaT(ut + _Y2000_IN_MJD) / 86400.0 class Time: + """Represents a date and time used for performing astronomy calculations. + """ def __init__(self, ut): self.ut = ut self.tt = _TerrestrialTime(ut) @@ -181,6 +183,16 @@ class Time: @staticmethod def Make(year, month, day, hour, minute, second): + """Creates a #Time object from a UTC calendar date and time. + + :param year: The UTC 4-digit year value, e.g. 2019. + :param month: The UTC month in the range 1..12. + :param day: The UTC day of the month, in the range 1..31. + :param hour: The UTC hour, in the range 0..23. + :param minute: The UTC minute, in the range 0..59. + :param second: The real-valued UTC second, in the range [0, 60). + :rtype: #Time + """ micro = round(math.fmod(second, 1.0) * 1000000) second = math.floor(second - micro/1000000) d = datetime.datetime(year, month, day, hour, minute, second, micro) @@ -213,6 +225,8 @@ class Time: class Observer: + """Represents the geographic location of an observer on the surface of the Earth. + """ def __init__(self, latitude, longitude, height=0): self.latitude = latitude self.longitude = longitude diff --git a/source/python/README.md b/source/python/README.md new file mode 100644 index 00000000..bd1b9f10 --- /dev/null +++ b/source/python/README.md @@ -0,0 +1,14 @@ +# astronomy + +## Time +```python +Time(self, ut) +``` +Represents a date and time used for performing astronomy calculations. + +## Observer +```python +Observer(self, latitude, longitude, height=0) +``` +Represents the geographic location of an observer on the surface of the Earth. + diff --git a/source/python/astronomy.py b/source/python/astronomy.py index 699cfa1d..d2b97267 100644 --- a/source/python/astronomy.py +++ b/source/python/astronomy.py @@ -265,6 +265,8 @@ def _TerrestrialTime(ut): return ut + _DeltaT(ut + _Y2000_IN_MJD) / 86400.0 class Time: + """Represents a date and time used for performing astronomy calculations. + """ def __init__(self, ut): self.ut = ut self.tt = _TerrestrialTime(ut) @@ -272,6 +274,16 @@ class Time: @staticmethod def Make(year, month, day, hour, minute, second): + """Creates a #Time object from a UTC calendar date and time. + + :param year: The UTC 4-digit year value, e.g. 2019. + :param month: The UTC month in the range 1..12. + :param day: The UTC day of the month, in the range 1..31. + :param hour: The UTC hour, in the range 0..23. + :param minute: The UTC minute, in the range 0..59. + :param second: The real-valued UTC second, in the range [0, 60). + :rtype: #Time + """ micro = round(math.fmod(second, 1.0) * 1000000) second = math.floor(second - micro/1000000) d = datetime.datetime(year, month, day, hour, minute, second, micro) @@ -304,6 +316,8 @@ class Time: class Observer: + """Represents the geographic location of an observer on the surface of the Earth. + """ def __init__(self, latitude, longitude, height=0): self.latitude = latitude self.longitude = longitude