Skip to content

Commit

Permalink
updating to handle all titles
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahanaFarooqui committed Dec 6, 2023
1 parent a790bfa commit aa39055
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
4 changes: 2 additions & 2 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ doc-wrongdir:
# doc/lightning-getlog.7 \
# doc/reckless.7
# REMOVE COMMENT AFTER TESTING
MANPAGES := doc/lightning-withdraw.7
MANPAGES := doc/lightning-feerates.7

ifeq ($(HAVE_SQLITE3),1)
MANPAGES += doc/lightning-listsqlschemas.7 \
Expand All @@ -154,7 +154,7 @@ check-doc: check-config-docs check-manpages check-fmt-schemas
# Some manpages use a schema, so need that added.
# MARKDOWN_WITH_SCHEMA := $(shell grep -l GENERATE-FROM-SCHEMA $(MANPAGES:=.md))
# REMOVE COMMENT AFTER TESTING
MARKDOWN_WITH_SCHEMA := doc/lightning-withdraw.7.md
MARKDOWN_WITH_SCHEMA := doc/lightning-feerates.7.md

# These are hard to use in $(call) functions.
LBRACKET=(
Expand Down
29 changes: 11 additions & 18 deletions tools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
if base_name not in grouped_files:
grouped_files.append(base_name)

grouped_files = ['feerates']
# Merge and create new JSON files
for base_name in grouped_files:
if os.path.exists(input_folder + "schemas/" + base_name + ".request.json") \
Expand All @@ -38,10 +39,6 @@
request_json.pop("deprecated", None)
description_line_s = 0
description_line_e = 0
author_line_s = 0
author_line_e = 0
see_also_line_s = 0
see_also_line_e = 0
md_file_contents = md_file.readlines()
for i, line in enumerate(md_file_contents):
if i == 0:
Expand All @@ -53,23 +50,19 @@
description_line_s = i + 3
if line.startswith("RETURN VALUE"):
description_line_e = i - 1
if line.startswith("AUTHOR"):
author_line_s = i + 3
if line.startswith("SEE ALSO"):
see_also_line_s = i + 3
author_line_e = i - 1
if line.startswith("RESOURCES"):
see_also_line_e = i - 1
md_file_contents[description_line_e - 1] = md_file_contents[description_line_e - 1].strip("\n")
md_file_contents[author_line_e - 1] = md_file_contents[author_line_e - 1].strip("\n")

description = md_file_contents[description_line_s:description_line_e]
authors = md_file_contents[author_line_s:author_line_e]
see_also = "".join(md_file_contents[see_also_line_s:see_also_line_e]).replace("\n", "").replace(" ", "").split(",")
title_line = md_file_contents[i - 1].strip("\n")
if line.startswith("----") and not (title_line.startswith("SYNOPSIS") or title_line.startswith("DESCRIPTION") or title_line.startswith("RETURN VALUE")):
for j in range(i+2, len(md_file_contents)):
if md_file_contents[j].startswith("----"):
title_line_end = j - 2
break
response_json[title_line.lower()] = md_file_contents[i+2:title_line_end]
break

md_file_contents[description_line_e - 1] = md_file_contents[description_line_e - 1].strip("\n")
description = md_file_contents[description_line_s:description_line_e]
request_json["description"] = description
merged_json["authors"] = authors
merged_json["seeAlso"] = see_also

response_json.pop("$schema", None)
response_json.pop("type", None)
Expand Down

0 comments on commit aa39055

Please sign in to comment.