@@ -23,19 +23,22 @@ def build_json_examples():
2323 index_md = """---
2424title: NGFF metadata JSON Examples
2525short_title: JSON Examples
26+ author: ""
2627---
2728
2829This section contains JSON examples for various metadata layouts.
2930"""
3031
3132 for example in example_types :
3233 json_files = glob .glob (os .path .join (input_directory , example , '*.json' ), recursive = True )
33- markdown_file_name = os .path .join (output_directory , f'{ example } .md' )
3434
3535 index_md += f"\n ## { example } \n "
3636
3737 # add header
38- markdown_content = f"""# { example } \n \n
38+ markdown_content = f"""---
39+ title: { example } Examples
40+ author: ""
41+ ---
3942
4043This document contains JSON examples for { example } metadata layouts.
4144
@@ -62,10 +65,10 @@ def build_json_examples():
6265```
6366"""
6467 # create
65- with open (markdown_file_name , 'w' ) as md_file :
68+ with open (os . path . join ( output_directory , f' { example } .md' ) , 'w' ) as md_file :
6669 md_file .write (markdown_content )
6770
68- with open (os .path .join ("examples.md" ), 'w' ) as index_file :
71+ with open (os .path .join ("_generated/ examples.md" ), 'w' ) as index_file :
6972 index_file .write (index_md )
7073
7174def build_json_schemas ():
@@ -78,15 +81,12 @@ def build_json_schemas():
7881 os .makedirs (output_directory , exist_ok = True )
7982 schema_files = glob .glob (os .path .join (schema_source_dir , '*.schema' ), recursive = True )
8083
81- # Create a resolver mapping for local schemas
82- schema_mapping = {}
83- for schema_file in schema_files :
84- with open (schema_file , 'r' ) as f :
85- schema_content = json .load (f )
86- if '$id' in schema_content :
87- schema_mapping [schema_content ['$id' ]] = os .path .abspath (schema_file )
8884
89- index_markdown = """# JSON Schemas
85+ index_markdown = """---
86+ title: NGFF metadata JSON Schemas
87+ short_title: JSON Schemas
88+ author: ""
89+ ---
9090
9191This section contains JSON schemas for various metadata layouts.
9292Find below links to auto-generated markdown pages or interactive HTML pages for each schema.
@@ -110,34 +110,39 @@ def build_json_schemas():
110110 config_md = GenerationConfiguration (
111111 template_name = 'md' ,
112112 with_footer = True ,
113- show_toc = False ,
114- link_to_reused_ref = False ,
115- custom_template_global_vars = { 'schema_mapping' : schema_mapping } )
113+ show_toc = True ,
114+ link_to_reused_ref = True ,
115+ )
116116 generate_from_filename (
117117 os .path .abspath (schema_file ),
118118 result_file_name = os .path .abspath (output_path_md ),
119119 config = config_md
120120 )
121121
122122 # insert mySt cross-reference at top of markdown files
123- with open (output_path_md , 'r' ) as md_file :
123+ with open (output_path_md , 'r' , encoding = 'utf-8' ) as md_file :
124124 md_content = md_file .read ()
125125 crossref = f"schemas:{ Path (schema_file ).stem } "
126- md_content = f"({ crossref } )=\n \n { md_content } "
127- with open (output_path_md , 'w' ) as md_file :
126+ md_content = f"""---
127+ author: ""
128+ ---
129+ ({ crossref } )=\n \n { md_content }
130+ """
131+ with open (output_path_md , 'w' , encoding = 'utf-8' ) as md_file :
128132 md_file .write (md_content )
129133
130134 link_markdown = f"[{ Path (schema_file ).stem } ](#{ crossref } )"
131- except Exception :
135+ except Exception as e :
136+ print (f"Error generating markdown for { schema_file } : { e } " )
132137 link_markdown = ""
133138
134139 try :
135140 config_html = GenerationConfiguration (
136141 template_name = 'js' ,
137142 with_footer = True ,
138143 show_toc = False ,
139- link_to_reused_ref = False ,
140- custom_template_global_vars = { 'schema_mapping' : schema_mapping } )
144+ link_to_reused_ref = True ,
145+ )
141146
142147 generate_from_filename (
143148 os .path .abspath (schema_file ),
@@ -146,12 +151,13 @@ def build_json_schemas():
146151 )
147152 link_html = f"[{ Path (schema_file ).stem } ]({ output_path_html } )"
148153
149- except Exception :
154+ except Exception as e :
155+ print (f"Error generating HTML for { schema_file } : { e } " )
150156 link_html = ""
151157
152158 index_markdown += f"| { Path (schema_file ).stem } | { link_markdown } | { link_html } |\n "
153159
154- with open (os .path .join ("schemas.md" ), 'w' ) as index_file :
160+ with open (os .path .join ("_generated/ schemas.md" ), 'w' ) as index_file :
155161 index_file .write (index_markdown )
156162
157163def build_footer ():
@@ -161,8 +167,7 @@ def build_footer():
161167 footer_content = f"""
162168<div>
163169 Copyright © 2020-{ year }
164- <a href="https://www.openmicroscopy.org/"><abbr title="Open Microscopy Environment">OME</abbr></a><sup>®</sup>
165- (<a href="https://dundee.ac.uk/"><abbr title="University of Dundee">U. Dundee</abbr></a>).
170+ <a href="https://www.openmicroscopy.org/"><abbr title="Open Microscopy Environment">OME</abbr></a><sup>®</sup>.
166171 OME trademark rules apply.
167172</div>
168173"""
0 commit comments