docs: Example notifications heading

- Added missing Example Notifications Heading
- Renamed `example_json_notifications` to `example_notifications`
- Moved `example_notifications` to the end of the page
This commit is contained in:
ShahanaFarooqui 2024-06-20 15:10:37 -07:00 committed by Christian Decker
parent 976c0c90bc
commit e94b793f05
5 changed files with 24 additions and 17 deletions

View file

@ -22726,7 +22726,13 @@
"",
"- -32602: Error in given parameters."
],
"example_json_notifications": [
"author": [
"Rusty Russell <<rusty@blockstream.com>> wrote the initial version of this man page."
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
],
"example_notifications": [
{
"method": "message",
"params": {
@ -22748,12 +22754,6 @@
}
}
],
"author": [
"Rusty Russell <<rusty@blockstream.com>> wrote the initial version of this man page."
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
],
"examples": [
{
"request": {

View file

@ -499,7 +499,7 @@
"type": "string"
}
},
"example_json_notifications": {
"example_notifications": {
"type": "array",
"items": {
"method": {

View file

@ -42,7 +42,13 @@
"",
"- -32602: Error in given parameters."
],
"example_json_notifications": [
"author": [
"Rusty Russell <<rusty@blockstream.com>> wrote the initial version of this man page."
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
],
"example_notifications": [
{
"method": "message",
"params": {
@ -64,12 +70,6 @@
}
}
],
"author": [
"Rusty Russell <<rusty@blockstream.com>> wrote the initial version of this man page."
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
],
"examples": [
{
"request": {

View file

@ -8,7 +8,7 @@ import re
# To maintain the sequence of the before return value (body) and after return value (footer) sections in the markdown file
BODY_KEY_SEQUENCE = ['reliability', 'usage', 'restriction_format', 'permitted_sqlite3_functions', 'treatment_of_types', 'tables', 'example_usage', 'notes', 'notifications', 'sharing_runes', 'riskfactor_effect_on_routing', 'recommended_riskfactor_values', 'optimality', 'randomization']
FOOTER_KEY_SEQUENCE = ['errors', 'trivia', 'author', 'see_also', 'resources', 'examples']
FOOTER_KEY_SEQUENCE = ['errors', 'trivia', 'author', 'see_also', 'resources', 'example_notifications', 'examples']
def output_title(title, underline='-', num_leading_newlines=1, num_trailing_newlines=2):
@ -487,6 +487,13 @@ def generate_footer(schema):
output_title(key.replace('_', ' ').upper(), '-', 1)
# Wrap see_also list with comma separated values
output(esc_underscores(', '.join(schema[key])))
elif key == 'example_notifications' and len(schema[key]) > 0:
output_title(key.replace('_', ' ').upper(), '-', 1)
for i, notification in enumerate(schema.get(key, [])):
output('{}**Notification {}**: {}\n'.format('' if i == 0 else '\n\n', i + 1, '\n'.join(notification.get('description', ''))))
output('```json\n')
output(json.dumps(notification, indent=2).strip() + '\n')
output('```')
elif key == 'examples' and len(schema[key]) > 0:
create_expandable('EXAMPLES', schema['rpc'], schema.get('examples', []))
else:

View file

@ -13,6 +13,6 @@ TITLE="$(basename "$(basename "$SOURCE" .md)" ."$SECTION" | tr '[:lower:]' '[:up
# format. mrkd used to do this for us, lowdown(1) doesn't.
TITLELINE="$(head -n1 "$SOURCE")"
SOURCE=$(tail -n +3 "$SOURCE" | sed -E ':a;N;$!ba;s#\s*<details>\s*<summary>\s*<span style="font-size: 1\.5em; font-weight: bold;">EXAMPLES</span><br>\s*</summary>#\n\nEXAMPLES\n------------\n#g; s#Request:#Request:\n#g; s#Response:#Response:\n#g; s#lightning-cli#lightning-cli:#g;')
SOURCE=$(tail -n +3 "$SOURCE" | sed -E ':a;N;$!ba;s#\s*<details>\s*<summary>\s*<span style="font-size: 1\.5em; font-weight: bold;">EXAMPLES</span><br>\s*</summary>#\n\nEXAMPLES\n------------\n#g; s#Request:#Request:\n#g; s#Response:#Response:\n#g; s#lightning-cli#lightning-cli:#g; s#\*\*Notification (1|2|3)\*\*:#**Notification \1**:\n#g;')
(echo "NAME"; echo "----"; echo "$TITLELINE"; echo "$SOURCE") | $LOWDOWN -s --out-no-smarty -Tman -m "title:$TITLE" -m "section:$SECTION" -m "source:Core Lightning $VERSION" -m "shiftheadinglevelby:-1"