Skip to content

Commit

Permalink
add tab for config json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
shirshanka committed Jun 3, 2022
1 parent d31c009 commit cee3e97
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions metadata-ingestion/scripts/docgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,11 @@ def generate(
os.makedirs(config_dir, exist_ok=True)
with open(f"{config_dir}/{plugin_name}_config.json", "w") as f:
f.write(source_config_class.schema_json(indent=2))

create_or_update(source_documentation,
[platform_id, "plugins", plugin_name, "config_schema"],
source_config_class.schema_json(indent=2) or "",
)

table_md = gen_md_table_from_struct(source_config_class.schema())
create_or_update(
Expand Down Expand Up @@ -644,6 +649,7 @@ def generate(

with open(platform_doc_file, "w") as f:
if "name" in platform_docs:
f.write(f"import Tabs from '@theme/Tabs';\nimport TabItem from '@theme/TabItem';\n\n")
f.write(f"# {platform_docs['name']}\n")
if len(platform_docs["plugins"].keys()) > 1:
# More than one plugin used to provide integration with this platform
Expand Down Expand Up @@ -716,6 +722,8 @@ def generate(
f.write("\n```\n")
if "config" in plugin_docs:
f.write("\n### Config Details\n")
f.write("""<Tabs>
<TabItem value="options" label="Options" default>\n\n""")
f.write(
"Note that a `.` is used to denote nested fields in the YAML recipe.\n\n"
)
Expand All @@ -725,6 +733,15 @@ def generate(
for doc in plugin_docs["config"]:
f.write(doc)
f.write("\n</details>\n\n")
f.write(f"""</TabItem>
<TabItem value="schema" label="Schema">
The [JSONSchema](https://json-schema.org/) for this configuration is inlined below.\n\n
```javascript
{plugin_docs['config_schema']}
```\n\n
</TabItem>
</Tabs>\n\n""")
# insert custom plugin docs after config details
f.write(plugin_docs.get("custom_docs", ""))
if "classname" in plugin_docs:
Expand Down

0 comments on commit cee3e97

Please sign in to comment.