Skip to content

Commit

Permalink
Fix bug in doc generation
Browse files Browse the repository at this point in the history
Signed-off-by: ClemensLinnhoff <[email protected]>
  • Loading branch information
ClemensLinnhoff committed Oct 23, 2024
1 parent 1616009 commit 6397591
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
15 changes: 4 additions & 11 deletions schemas/material_brdf_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,10 @@
},
"wavelengthRange": {
"type": "array",
"description": "Wavelength range covered by the lookup table.",
"items": [
{
"type": "number",
"description": "Min wavelength in meters."
"description": "Wavelength range covered by the lookup table. The first item is the minimum wavelength in meters and the second item is the maximum wavelength in meters.",
"items": {
"type": "number"
},
{
"type": "number",
"description": "Max wavelength in meters."
}
],
"minItems": 2,
"maxItems": 2
},
Expand All @@ -95,9 +88,9 @@
},
"lookupTable": {
"type": "array",
"description": "Array of bidirectional reflectance distribution function (BRDF) values, with each item representing a different property. The array SHALL be sorted based on the columns starting with the first.",
"items": {
"type": "array",
"description": "Array of bidirectional reflectance distribution function (BRDF) values, with each item representing a different property. The array SHALL be sorted based on the columns starting with the first.",
"items": [
{
"type": ["number", "null"],
Expand Down
2 changes: 1 addition & 1 deletion schemas/material_emp_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
},
"electromagneticProperties": {
"type": "array",
"description": "Array of electromagnetic property values, with each item representing a different property. The array SHALL be sorted based on the columns starting with the first.",
"items": {
"type": "array",
"description": "Array of electromagnetic property values, with each item representing a different property. The array SHALL be sorted based on the columns starting with the first.",
"items": [
{
"type": ["number", "null"],
Expand Down
7 changes: 5 additions & 2 deletions scripts/json2asciidoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,22 @@ def generate_asciidoc_properties(properties, required_fields, level=2):
for prop_name, prop_data in properties.items():
heading_prefix = "=" * level # Create heading based on level
asciidoc_content += f"{heading_prefix} {prop_name}\n"
asciidoc_content += f"{prop_data.get('description', 'No description')}\n"
asciidoc_content += f"{prop_data.get('description', '')}\n"

# Handle array types and generate description for array of arrays
if prop_data.get('type') == "array":
if isinstance(prop_data['items'], dict) and 'items' in prop_data['items']:
# Generate list for array of arrays
asciidoc_content += "Instance\n"
asciidoc_content += generate_asciidoc_array_of_arrays(prop_data['items']['items'], prop_data['items'].get('description', '')) + "\n"
elif isinstance(prop_data['items'], list):
# If it's a list of items, generate columns description directly
asciidoc_content += "list\n"
asciidoc_content += generate_asciidoc_array_of_arrays(prop_data['items'], prop_data.get('description', '')) + "\n"
else:
# Simple array, include the description of the array
asciidoc_content += f"\n{prop_data['items'].get('description', 'No description')}\n"
asciidoc_content += "simple\n"
asciidoc_content += f"\n{prop_data['items'].get('description', '')}\n"

# Add pattern inline and handle escaping of backslashes and curly braces
if "pattern" in prop_data:
Expand Down

0 comments on commit 6397591

Please sign in to comment.