Skip to content

Commit 2d703fc

Browse files
ShahanaFarooquirustyrussell
authored andcommitted
tools: Removed lightning- for schema filename before generating markdowns
1 parent 23364cc commit 2d703fc

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

tools/fromschema.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def create_shell_command(rpc, example):
325325

326326
def generate_header(schema):
327327
"""Generate lines for rpc title and synopsis with request parameters"""
328-
output_title(esc_underscores(''.join(['lightning-', schema['rpc'], ' -- ', schema['title']])), '=', 0, 1)
328+
output_title(esc_underscores(''.join([schema['rpc'], ' -- ', schema['title']])), '=', 0, 1)
329329
output_title('SYNOPSIS')
330330
# Add command level warning if exists
331331
if 'warning' in schema:
@@ -364,8 +364,8 @@ def generate_header(schema):
364364
# Print the key as it is if it doesn't exist in conditional array
365365
output('{}'.format(fmt_paramname(toplevels[i], False if 'required' in request and toplevels[i] in request['required'] else True)))
366366
i += 1
367-
# lightning-plugin.json is an exception where all parameters cannot be printed deu to their dependency on different subcommands
368-
# So, add ... at the end for lightning-plugin schema
367+
# plugin.json is an exception where all parameters cannot be printed deu to their dependency on different subcommands
368+
# So, add ... at the end for plugin schema
369369
if schema['rpc'] == 'plugin':
370370
output('...')
371371
output('\n')

tools/md2man.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,21 @@ if [ $# != 2 ]; then
66
fi
77
LOWDOWN="$1"
88
SOURCE="$2"
9+
10+
TARGET="$SOURCE"
11+
12+
# Extract the directory and filename separately
13+
DIR="$(dirname "$SOURCE")"
14+
FILE="$(basename "$SOURCE" .md)"
15+
16+
# Check if the file doesn't already start with 'lightningd' or 'lightning-'
17+
if [ "${FILE#lightningd}" = "$FILE" ] && [ "${FILE#lightning-}" = "$FILE" ]; then
18+
TARGET="$DIR/lightning-$FILE"
19+
fi
20+
TARGET="${TARGET%.md}"
21+
922
SECTION="$(basename "$SOURCE" .md | cut -d. -f2-)"
10-
TITLE="$(basename "$(basename "$SOURCE" .md)" ."$SECTION" | tr '[:lower:]' '[:upper:]')"
23+
TITLE="$(basename "$(basename "$TARGET" .md)" ."$SECTION" | tr '[:lower:]' '[:upper:]')"
1124

1225
# First two lines are title, which needs to be turned into NAME for proper manpage
1326
# format. mrkd used to do this for us, lowdown(1) doesn't.
@@ -26,4 +39,5 @@ SOURCE=$(tail -n +3 "$SOURCE" | sed -E '
2639
s#\*\*Notification (1|2|3)\*\*:#**Notification \1**:\n#g;
2740
')
2841

29-
(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"
42+
# Output to the target file
43+
(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" > "$TARGET"

0 commit comments

Comments
 (0)