Skip to content

Commit

Permalink
Kotlin docs: more enum cleanup.
Browse files Browse the repository at this point in the history
I missed a couple of places where I want to remove
private constructor calls from enum members.
Also, discard [name] and [ordinal] links while preserving
other properties that are intentionally exposed.
  • Loading branch information
cosinekitty committed Apr 25, 2022
1 parent b7c7733 commit d130405
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
17 changes: 15 additions & 2 deletions generate/kotlindoc/format_kotlin_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
'Saturn',
'Uranus',
'Neptune',
'Pluto'
'Pluto',
'Rise',
'Set'
]


Expand All @@ -47,11 +49,22 @@ def RemoveEnumProperties(text):
prefix = '## Properties'
sectionIndex = text.find(prefix)
if sectionIndex >= 0:
tail = text[sectionIndex + len(prefix):]
rowsIndex = sectionIndex + len(prefix)
tail = text[rowsIndex:]
nameSet = set(re.findall(r'\n\|\s+\[(\S+)\]', tail))
if nameSet == set(['name', 'ordinal']):
# Truncate the markdown text right before '## Properties'
return text[:sectionIndex]

# If there are other properties besides 'name' and 'ordinal',
# keep the other properties but get rid of 'name' and 'ordinal'.
if ('name' in nameSet) and ('ordinal' in nameSet):
rows = tail.split('\n')
fix = text[:rowsIndex]
for r in rows:
if (not r.startswith('| [name]')) and (not r.startswith('| [ordinal]')):
fix += r + '\n'
return fix
# Return the entire text, unmodified.
return text

Expand Down
5 changes: 1 addition & 4 deletions source/kotlin/doc/-direction/-rise/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

# Rise

[Rise](index.md)(+1)

Indicates a rising event: a celestial body is observed to rise above the horizon by an observer on the Earth.

## Properties

| Name | Summary |
|---|---|
| [name](../../-node-event-kind/-ascending/index.md#-372974862%2FProperties%2F-1216412040)<br>val [name](../../-node-event-kind/-ascending/index.md#-372974862%2FProperties%2F-1216412040): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
| [ordinal](../../-node-event-kind/-ascending/index.md#-739389684%2FProperties%2F-1216412040)<br>val [ordinal](../../-node-event-kind/-ascending/index.md#-739389684%2FProperties%2F-1216412040): [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) |
| [sign](../sign.md)<br>val [sign](../sign.md): [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)<br>A numeric value that is helpful in formulas involving rise/set. The sign is +1 for a rising event, or -1 for a setting event. |

5 changes: 1 addition & 4 deletions source/kotlin/doc/-direction/-set/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

# Set

[Set](index.md)(-1)

Indicates a setting event: a celestial body is observed to sink below the horizon by an observer on the Earth.

## Properties

| Name | Summary |
|---|---|
| [name](../../-node-event-kind/-ascending/index.md#-372974862%2FProperties%2F-1216412040)<br>val [name](../../-node-event-kind/-ascending/index.md#-372974862%2FProperties%2F-1216412040): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
| [ordinal](../../-node-event-kind/-ascending/index.md#-739389684%2FProperties%2F-1216412040)<br>val [ordinal](../../-node-event-kind/-ascending/index.md#-739389684%2FProperties%2F-1216412040): [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) |
| [sign](../sign.md)<br>val [sign](../sign.md): [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)<br>A numeric value that is helpful in formulas involving rise/set. The sign is +1 for a rising event, or -1 for a setting event. |

7 changes: 3 additions & 4 deletions source/kotlin/doc/-direction/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ Selects whether to search for a rising event or a setting event for a celestial

| | |
|---|---|
| [Rise](-rise/index.md)<br>[Rise](-rise/index.md)(+1)<br>Indicates a rising event: a celestial body is observed to rise above the horizon by an observer on the Earth. |
| [Set](-set/index.md)<br>[Set](-set/index.md)(-1)<br>Indicates a setting event: a celestial body is observed to sink below the horizon by an observer on the Earth. |
| [Rise](-rise/index.md)<br>Indicates a rising event: a celestial body is observed to rise above the horizon by an observer on the Earth. |
| [Set](-set/index.md)<br>Indicates a setting event: a celestial body is observed to sink below the horizon by an observer on the Earth. |

## Properties

| Name | Summary |
|---|---|
| [name](../-node-event-kind/-ascending/index.md#-372974862%2FProperties%2F-1216412040)<br>val [name](../-node-event-kind/-ascending/index.md#-372974862%2FProperties%2F-1216412040): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
| [ordinal](../-node-event-kind/-ascending/index.md#-739389684%2FProperties%2F-1216412040)<br>val [ordinal](../-node-event-kind/-ascending/index.md#-739389684%2FProperties%2F-1216412040): [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) |
| [sign](sign.md)<br>val [sign](sign.md): [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)<br>A numeric value that is helpful in formulas involving rise/set. The sign is +1 for a rising event, or -1 for a setting event. |

0 comments on commit d130405

Please sign in to comment.