Skip to content

Commit

Permalink
Merge pull request #1116 from Avaiga/doc/#1114-fix-image-links-and-re…
Browse files Browse the repository at this point in the history
…st-refman

Fix image links and rest refman
  • Loading branch information
FlorianJacta authored Sep 9, 2024
2 parents aee9476 + ed5668e commit b32e775
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
8 changes: 4 additions & 4 deletions docs/userman/gui/extension/dynamic_element/scalar_props.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ We can see how the *label* property of the control is bound to the Python variab
When you run this application, the page displays the element like this:

<figure>
<img src="./scalar1-d.png" class="visible-dark" width="80%"/>
<img src="./scalar1-l.png" class="visible-light" width="80%"/>
<img src="../scalar1-d.png" class="visible-dark" width="80%"/>
<img src="../scalar1-l.png" class="visible-light" width="80%"/>
<figcaption>Colored Label</figcaption>
</figure>

Expand All @@ -142,7 +142,7 @@ def on_action(state, id):
If the user click the button a few times, this is what the page would look like:

<figure>
<img src="./scalar2-d.png" class="visible-dark" width="80%"/>
<img src="./scalar2-l.png" class="visible-light" width="80%"/>
<img src="../scalar2-d.png" class="visible-dark" width="80%"/>
<img src="../scalar2-l.png" class="visible-light" width="80%"/>
<figcaption>With trailing random characters</figcaption>
</figure>
36 changes: 25 additions & 11 deletions tools/_setup_generation/step_rest_refman.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get_property_type(property_desc, from_schemas):
if dest_path in enterprise_paths:
file.write(Setup.ENTERPRISE_BANNER)
file.write(f"{dest_path_desc}\n\n")
self.navigation += f"- \"Paths for {dest_path}\": {REST_REF_DIR_PATH}/apis_{dest_path}.md\n"
self.navigation += f'- "Paths for {dest_path}": refmans/reference_rest/apis_{dest_path}.md\n'
path_files[dest_path] = file

file.write(f"# `{path}`\n\n")
Expand All @@ -122,10 +122,16 @@ def get_property_type(property_desc, from_schemas):
file.write("\n")
request_body = method_desc.get("requestBody")
if request_body is not None:
file.write(f'<div><h4 style="display: inline-block;">Request body:</h4>\n')
schema = request_body["content"]["application/json"]["schema"]["$ref"]
file.write(
f'<div><h4 style="display: inline-block;">Request body:</h4>\n'
)
schema = request_body["content"]["application/json"]["schema"][
"$ref"
]
schema = schema[schema.rfind("/") + 1 :]
file.write(f'<span><a href="schemas.md#{schema.lower()}">{schema}</a></div>\n\n')
file.write(
f'<span><a href="schemas.md#{schema.lower()}">{schema}</a></div>\n\n'
)
responses = method_desc.get("responses")
if responses is not None:
file.write(f"<h4>Responses</h4>\n\n")
Expand All @@ -147,11 +153,17 @@ def get_property_type(property_desc, from_schemas):
file.write(" |Name|Type|\n")
file.write(" |---|---|\n")
for property, property_desc in properties.items():
file.write(f" |{property}|{get_property_type(property_desc, False)}|\n")
file.write(
f" |{property}|{get_property_type(property_desc, False)}|\n"
)
else:
print(f"No properties in content in response {response} in method {method} of {path}")
print(
f"No properties in content in response {response} in method {method} of {path}"
)
elif response != "404":
print(f"No content in response {response} in method {method} of {path}")
print(
f"No content in response {response} in method {method} of {path}"
)
file.write("\n")

for f in path_files.values():
Expand All @@ -165,12 +177,14 @@ def get_property_type(property_desc, from_schemas):
file.write("|Name|Type|Description|\n")
file.write("|---|---|---|\n")
for property, property_desc in properties.items():
file.write(f"|{property}|{get_property_type(property_desc, True)}|-|\n")
file.write(
f"|{property}|{get_property_type(property_desc, True)}|-|\n"
)
file.write("\n")
self.navigation += "- \"Schemas\": " + REST_REF_DIR_PATH + "/schemas.md\n"

self.navigation += '- "Schemas": ' + "refmans/reference_rest/schemas.md\n"

def exit(self, setup: Setup):
setup.update_mkdocs_yaml_template(
r"^\s*\[REST_REFERENCE_CONTENT\]\s*\n", self.navigation if self.navigation else ""
r"^\s*\[REST_REFERENCE_CONTENT\]\s*\n",
self.navigation if self.navigation else "",
)

0 comments on commit b32e775

Please sign in to comment.