script: Auto generate rpc examples for documentation

I will commit doc/schemas/lightning-*.json files separately to keep this commit easier to review.

- test-autogenerate-rpc-examples updates all example request & responses in doc/schemas/lightning-*.json files.

- Updated tools/fromschema.py to accommodate the sql JSON example requirement where it does not accept -o in the query but shell does (for queries containing the = sign).

Changelog-None.
This commit is contained in:
ShahanaFarooqui 2024-07-12 21:16:36 -07:00
parent fe7981bda2
commit 50faa7c122
3 changed files with 1211 additions and 1 deletions

1
.gitignore vendored
View File

@ -92,3 +92,4 @@ release/
# Ignore release verification Sha256Sums
SHA256SUMS-*
doc/.doc_version
autogenerate-examples-status.log

File diff suppressed because it is too large Load Diff

View File

@ -297,6 +297,11 @@ def create_shell_command(rpc, example):
shell_command = f'lightning-cli {rpc} '
if 'params' in example['request']:
if isinstance(example['request']['params'], list):
if rpc == 'sql' and example['request']['params'] and '=' in example['request']['params'][0]:
# For SQL queries in shell, prepend '-o' flag to the query
query = example['request']['params'][0]
shell_command += f"-o '{query}'" if "'" not in query else f'-o "{query}"'
else:
shell_command += ' '.join(f'"{item}"' for item in example['request']['params'])
elif example['request']['params'].items():
shell_command += '-k '