mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-01-16 11:28:18 -05:00
Python: escape examples as code blocks in Markdown.
This commit is contained in:
@@ -71,6 +71,8 @@ class DocInfo:
|
||||
mode = line
|
||||
continue
|
||||
if line.strip() == '':
|
||||
if mode == 'code':
|
||||
self.description += '```\n'
|
||||
mode = ''
|
||||
continue
|
||||
if mode == 'Parameters':
|
||||
@@ -84,9 +86,16 @@ class DocInfo:
|
||||
elif mode == 'Values':
|
||||
self.ProcessEnumValue(line)
|
||||
elif mode == '':
|
||||
if re.match(r'^\s*>>>', line):
|
||||
mode = 'code'
|
||||
self.description += '```\n'
|
||||
self.description += line + '\n'
|
||||
elif mode == 'code':
|
||||
self.description += line + '\n'
|
||||
else:
|
||||
raise Exception('Unknown mode = "{}"'.format(mode))
|
||||
if mode == 'code':
|
||||
self.description += '```\n'
|
||||
|
||||
def ProcessEnumValue(self, line):
|
||||
m = re.match(r'^\s*([A-Za-z][A-Za-z0-9_]+)\s*:\s*(.*)$', line)
|
||||
|
||||
@@ -144,8 +144,10 @@ as seen by an observer on the surface of the Earth.
|
||||
|
||||
**Finds the Body enumeration value, given the name of a body.**
|
||||
|
||||
```
|
||||
>>> astronomy.BodyCode('Mars')
|
||||
<Body.Mars: 3>
|
||||
```
|
||||
|
||||
|
||||
| Type | Parameter | Description |
|
||||
|
||||
Reference in New Issue
Block a user