mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-04-04 14:55:38 -04:00
Baby step in converting Python docstrings to Markdown.
This commit is contained in:
@@ -271,7 +271,7 @@ class Time:
|
||||
such as calculating rise/set times, culumination, and anything involving apparent
|
||||
sidereal time.
|
||||
Before the era of atomic timekeeping, days based on the Earth's rotation
|
||||
were often known as <i>mean solar days</i>.
|
||||
were often known as *mean solar days*.
|
||||
tt : float
|
||||
Terrestrial Time days since noon on January 1, 2000.
|
||||
Terrestrial Time is an atomic time scale defined as a number of days since noon on January 1, 2000.
|
||||
@@ -281,7 +281,7 @@ class Time:
|
||||
for changes in the Earth's rotation.
|
||||
The value in `tt` is used for calculations of movements not involving the Earth's rotation,
|
||||
such as the orbits of planets around the Sun, or the Moon around the Earth.
|
||||
Historically, Terrestrial Time has also been known by the term <i>Ephemeris Time</i> (ET).
|
||||
Historically, Terrestrial Time has also been known by the term *Ephemeris Time* (ET).
|
||||
"""
|
||||
def __init__(self, ut):
|
||||
self.ut = ut
|
||||
@@ -707,7 +707,7 @@ def GeoMoon(time:Time) -> Vector:
|
||||
The vector gives the location of the Moon's center relative to the Earth's center
|
||||
with x-, y-, and z-components measured in astronomical units.
|
||||
|
||||
This algorithm is based on Nautical Almanac Office's <i>Improved Lunar Ephemeris</i> of 1954,
|
||||
This algorithm is based on Nautical Almanac Office's *Improved Lunar Ephemeris* of 1954,
|
||||
which in turn derives from E. W. Brown's lunar theories from the early twentieth century.
|
||||
It is adapted from Turbo Pascal code from the book
|
||||
[Astronomy on the Personal Computer](https://www.springer.com/us/book/9783540672210)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import importlib
|
||||
import inspect
|
||||
|
||||
@@ -21,8 +22,35 @@ def LoadModule(inPythonFileName):
|
||||
module = importlib.import_module(modname)
|
||||
return module
|
||||
|
||||
def HtmlEscape(text):
|
||||
text = text.replace('&', '&')
|
||||
text = text.replace('->', '⇒')
|
||||
text = text.replace('<', '<')
|
||||
text = text.replace('>', '>')
|
||||
return text
|
||||
|
||||
def MdDocString(doc):
|
||||
return doc
|
||||
lines = doc.split('\n')
|
||||
md = ''
|
||||
mode = ''
|
||||
for line in lines:
|
||||
if re.match(r'^\-+$', line):
|
||||
continue
|
||||
if line in ['Parameters', 'Returns', 'Example', 'Properties']:
|
||||
mode = line
|
||||
continue
|
||||
if line.strip() == '':
|
||||
mode = ''
|
||||
md += '\n'
|
||||
continue
|
||||
text = HtmlEscape(line)
|
||||
md += text + '\n'
|
||||
return md
|
||||
|
||||
def MdSignature(sig):
|
||||
text = str(sig)
|
||||
text = HtmlEscape(text)
|
||||
return text
|
||||
|
||||
def MdFunction(func):
|
||||
md = ''
|
||||
@@ -33,7 +61,7 @@ def MdFunction(func):
|
||||
md += '---\n'
|
||||
md += '\n'
|
||||
md += '<a name="{}"></a>\n'.format(func.__name__)
|
||||
md += '### ' + func.__name__ + str(sig) + '\n'
|
||||
md += '### ' + func.__name__ + MdSignature(sig) + '\n'
|
||||
md += MdDocString(doc) + '\n'
|
||||
md += '\n'
|
||||
return md
|
||||
|
||||
@@ -7,58 +7,51 @@
|
||||
---
|
||||
|
||||
<a name="BodyCode"></a>
|
||||
### BodyCode(name) -> astronomy.Body
|
||||
### BodyCode(name) ⇒ astronomy.Body
|
||||
Finds the Body enumeration value, given the name of a body.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name: str
|
||||
The common English name of a supported celestial body.
|
||||
|
||||
Returns
|
||||
-------
|
||||
Body
|
||||
If `name` is a valid body name, returns the enumeration
|
||||
value associated with that body.
|
||||
Otherwise, returns `Body.Invalid`.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
>>> astronomy.BodyCode('Mars')
|
||||
<Body.Mars: 3>
|
||||
>>> astronomy.BodyCode('Mars')
|
||||
<Body.Mars: 3>
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
<a name="GeoMoon"></a>
|
||||
### GeoMoon(time: astronomy.Time) -> astronomy.Vector
|
||||
### GeoMoon(time: astronomy.Time) ⇒ astronomy.Vector
|
||||
Calculates the geocentric position of the Moon at a given time.
|
||||
|
||||
Given a time of observation, calculates the Moon's position as a vector.
|
||||
The vector gives the location of the Moon's center relative to the Earth's center
|
||||
with x-, y-, and z-components measured in astronomical units.
|
||||
|
||||
This algorithm is based on Nautical Almanac Office's <i>Improved Lunar Ephemeris</i> of 1954,
|
||||
This algorithm is based on Nautical Almanac Office's *Improved Lunar Ephemeris* of 1954,
|
||||
which in turn derives from E. W. Brown's lunar theories from the early twentieth century.
|
||||
It is adapted from Turbo Pascal code from the book
|
||||
[Astronomy on the Personal Computer](https://www.springer.com/us/book/9783540672210)
|
||||
by Montenbruck and Pfleger.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
time : Time
|
||||
The date and time for which to calculate the Moon's position.
|
||||
|
||||
Returns
|
||||
-------
|
||||
Vector
|
||||
The Moon's position as a vector in J2000 Cartesian equatorial coordinates.
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
<a name="unique"></a>
|
||||
### unique(enumeration)
|
||||
Class decorator for enumerations ensuring unique member values.
|
||||
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ class Time:
|
||||
such as calculating rise/set times, culumination, and anything involving apparent
|
||||
sidereal time.
|
||||
Before the era of atomic timekeeping, days based on the Earth's rotation
|
||||
were often known as <i>mean solar days</i>.
|
||||
were often known as *mean solar days*.
|
||||
tt : float
|
||||
Terrestrial Time days since noon on January 1, 2000.
|
||||
Terrestrial Time is an atomic time scale defined as a number of days since noon on January 1, 2000.
|
||||
@@ -372,7 +372,7 @@ class Time:
|
||||
for changes in the Earth's rotation.
|
||||
The value in `tt` is used for calculations of movements not involving the Earth's rotation,
|
||||
such as the orbits of planets around the Sun, or the Moon around the Earth.
|
||||
Historically, Terrestrial Time has also been known by the term <i>Ephemeris Time</i> (ET).
|
||||
Historically, Terrestrial Time has also been known by the term *Ephemeris Time* (ET).
|
||||
"""
|
||||
def __init__(self, ut):
|
||||
self.ut = ut
|
||||
@@ -2021,7 +2021,7 @@ def GeoMoon(time:Time) -> Vector:
|
||||
The vector gives the location of the Moon's center relative to the Earth's center
|
||||
with x-, y-, and z-components measured in astronomical units.
|
||||
|
||||
This algorithm is based on Nautical Almanac Office's <i>Improved Lunar Ephemeris</i> of 1954,
|
||||
This algorithm is based on Nautical Almanac Office's *Improved Lunar Ephemeris* of 1954,
|
||||
which in turn derives from E. W. Brown's lunar theories from the early twentieth century.
|
||||
It is adapted from Turbo Pascal code from the book
|
||||
[Astronomy on the Personal Computer](https://www.springer.com/us/book/9783540672210)
|
||||
|
||||
Reference in New Issue
Block a user