Skip to content
Snippets Groups Projects
Commit 4ac51cb1 authored by Artur Sabirov's avatar Artur Sabirov Committed by Yaroslav Dynnikov
Browse files

rpc_api.md: fix sorting

parent 7b11c93c
No related branches found
No related tags found
1 merge request!524rpc_api.md: fix sorting
Pipeline #48807 passed
This diff is collapsed.
...@@ -15,6 +15,8 @@ def on_page_markdown(markdown: str, page: Page, config: MkDocsConfig, files: Fil ...@@ -15,6 +15,8 @@ def on_page_markdown(markdown: str, page: Page, config: MkDocsConfig, files: Fil
return reference_cli(markdown, page) return reference_cli(markdown, page)
elif page.file.src_uri == "reference/audit_events.md": elif page.file.src_uri == "reference/audit_events.md":
return reference_audit_events(markdown, page) return reference_audit_events(markdown, page)
elif page.file.src_uri == "architecture/rpc_api.md":
return reference_rpc_api(markdown, page)
def reference_cli(markdown: str, page: Page): def reference_cli(markdown: str, page: Page):
...@@ -49,3 +51,27 @@ def reference_audit_events(markdown: str, page: Page): ...@@ -49,3 +51,27 @@ def reference_audit_events(markdown: str, page: Page):
log.warning(f"INCORRECT SORTING @ {page.file.src_uri}") log.warning(f"INCORRECT SORTING @ {page.file.src_uri}")
diff = difflib.unified_diff(h3, h3_sorted) diff = difflib.unified_diff(h3, h3_sorted)
log.info("\n" + "\n".join(diff)) log.info("\n" + "\n".join(diff))
def reference_rpc_api(markdown: str, page: Page):
lines: list[str] = re.sub("<!--.*?-->", "", markdown, flags=re.DOTALL).split("\n")
headers: list[str] = list(filter(lambda line: re.match("^##+ ", line), lines))
last_h2: str = ""
index: dict[str, list[str]] = dict()
for h in headers:
if h.startswith("## "):
last_h2 = h
index[last_h2] = []
elif h.startswith("### ") and ".proc" in h:
arg = re.findall(r"\.[\w_]+", h)[0]
index[last_h2].append(arg)
for h2, args in index.items():
if "Service API" not in h2:
continue
args_sorted = sorted(args)
if args != args_sorted:
log.warning(f"INCORRECT SORTING @ {page.file.src_uri}: {h2}")
diff = difflib.unified_diff(args, args_sorted)
log.info("\n" + "\n".join(diff))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment