Conversation
…ering Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
|
I want the pretty prick to utilized colors based on the type of source code is being displaced. JSON or others. What libraries do we have that would be compatible with current JavaScript deployment? @copilot |
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Added highlight.js 11.9.0 (commit
The Here's the JSON Schema tab with syntax highlighting active: |
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
|
I expected to a CA Json schema tab here |
|
@copilot see previous |
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Fixed in commit The fix uses |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
❌ Deployment FailedBranch: Deployment failed. Please check the build log for details. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
|
@copilot json non-dynamich has linka https://worldhealthorganization.github.io/smart-immunizations/PlanDefinition-IMMZD2DTHib2DosesWithBoosterDose.json.html |
…ty name quotes as HTML entities) Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Fixed in commit The fix updates the JSON regex to Once the CI build completes, FHIR documentation links will appear on property names in dynamically-loaded JSON, XML, and TTL pages (links were already correct for XML/TTL since those use element/attribute names without quotes). Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Build error @copilot |
… group Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Fixed in commit The error was a race condition — two concurrent branch builds each fetched the Root cause: the concurrency group was Fix: changed the concurrency group to |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
|
Set cancel-in-progress: false @copilot |
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Done in commit |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
✅ Deployment SuccessfulBranch:
Deployment completed successfully! The site is now live at the URL above. |
|
Merge upstream changes @copilot |
I'm unable to pull branches from GitHub or perform the merge directly. Please run the following to merge upstream changes into this branch: git fetch origin
git merge origin/mainIf there are merge conflicts, please resolve them and push. Once that's done, I can continue addressing any remaining issues. |
There was a problem hiding this comment.
Pull request overview
This PR enhances the generated FHIR IG HTML output by adding a dedicated JSON Schema navigation tab for logical model pages and reducing page bloat via lazy, client-side source rendering (Prism.js + fetch), while also adjusting the GitHub Actions workflow to improve gh-pages deployment reliability.
Changes:
- Add a “JSON Schema” nav tab to StructureDefinition (logical model) pages and generate companion
*.schema.json.htmlpages with Prism-highlighted, lazily loaded schema content and FHIR doc links. - Replace large embedded JSON/XML/TTL
<pre>blocks with dynamic fetch-based loading + Prism highlighting (and restore FHIR documentation links after highlighting). - Update CI to serialize gh-pages deployments, deploy from the actual branch name, and fix
output/permissions for post-processing.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
input/scripts/generate_dak_api_hub.py |
Generates schema view pages, injects schema tab links, and implements dynamic source loading + FHIR doc link restoration. |
.github/workflows/ghbuild.yml |
Adds concurrency controls, uses actual branch name for deploy context, and ensures output/ is writable before DAK post-processing. |
.gitignore |
Ignores Node-related local artifacts (node_modules/, lockfile, package manifest). |
| depth = 0 | ||
| i = start | ||
| n = len(html) | ||
| while i < n: | ||
| j = html.find('<', i) | ||
| if j == -1: | ||
| break | ||
| # Opening div | ||
| if j + 4 <= n and html[j:j+4].lower() == '<div' and (j + 4 >= n or html[j+4] in ' \t\n\r>/'): | ||
| end_tag = html.find('>', j) | ||
| if end_tag == -1: | ||
| break | ||
| if end_tag > 0 and html[end_tag - 1] == '/': | ||
| # Self-closing <div/> – no depth change | ||
| i = end_tag + 1 | ||
| else: | ||
| depth += 1 | ||
| i = end_tag + 1 | ||
| # Closing div | ||
| elif html[j:j+6].lower() == '</div>': | ||
| depth -= 1 | ||
| if depth == 0: | ||
| return j + 6 | ||
| i = j + 6 | ||
| else: | ||
| i = j + 1 | ||
| return -1 |
There was a problem hiding this comment.
The new helper _find_closing_div() is not referenced anywhere in this module (no call sites). Consider removing it or wiring it into _generate_schema_view_page() so dead code doesn’t accumulate and future readers don’t assume it’s part of the logic.
| depth = 0 | |
| i = start | |
| n = len(html) | |
| while i < n: | |
| j = html.find('<', i) | |
| if j == -1: | |
| break | |
| # Opening div | |
| if j + 4 <= n and html[j:j+4].lower() == '<div' and (j + 4 >= n or html[j+4] in ' \t\n\r>/'): | |
| end_tag = html.find('>', j) | |
| if end_tag == -1: | |
| break | |
| if end_tag > 0 and html[end_tag - 1] == '/': | |
| # Self-closing <div/> – no depth change | |
| i = end_tag + 1 | |
| else: | |
| depth += 1 | |
| i = end_tag + 1 | |
| # Closing div | |
| elif html[j:j+6].lower() == '</div>': | |
| depth -= 1 | |
| if depth == 0: | |
| return j + 6 | |
| i = j + 6 | |
| else: | |
| i = j + 1 | |
| return -1 | |
| # NOTE: This helper was previously implemented but never called anywhere | |
| # in this module. It has been removed to avoid accumulating dead code and | |
| # confusing future maintainers into thinking it is part of the logic. | |
| raise NotImplementedError("_find_closing_div is unused and has been removed") |
| def _generate_schema_tab_pane_html(self, schema_filename: str, tab_id: str, | ||
| language: str = 'json') -> str: | ||
| """ | ||
| Generate the HTML for a content tab pane that lazily loads a source file | ||
| via JavaScript and applies client-side syntax highlighting. | ||
|
|
||
| Cross-domain / CORS note | ||
| ------------------------ | ||
| The ``fetch()`` call uses a *relative* URL (same directory as the HTML | ||
| page), so it is always same-origin regardless of whether the site is | ||
| deployed to github.io, smart.who.int, or any other domain. There is no | ||
| cross-origin request and therefore no CORS error is possible. | ||
|
|
||
| Syntax-highlighter strategy | ||
| --------------------------- | ||
| Syntax highlighting is provided exclusively by **Prism.js**, which is | ||
| already bundled by the FHIR IG Publisher's standard template | ||
| (hl7.fhir.template / who.template.root). No CDN request is made, so | ||
| there are no Content Security Policy (CSP) concerns regardless of the | ||
| deployment domain. | ||
|
|
||
| ``Prism.highlightElement(el)`` is called when ``window.Prism`` is | ||
| available and the requested language grammar is registered. Languages | ||
| not registered in Prism (``Prism.languages[language]`` is falsy, e.g. | ||
| ``cql``) fall through to plain formatted text — no silent failure. | ||
|
|
||
| Other options considered and rejected: | ||
|
|
||
| - **highlight.js** — requires an external CDN request; may be blocked | ||
| by strict CSP on domains such as smart.who.int. | ||
| - **CodeMirror** — full interactive editor, 6× heavier; designed for | ||
| editing not read-only display. | ||
|
|
||
| If Prism is unavailable the JSON is still pretty-printed via | ||
| ``JSON.stringify(d, null, 2)`` — fully readable, just without colours. | ||
|
|
||
| Args: | ||
| schema_filename: Relative URL of the source file to load. | ||
| Must be same-origin (relative path). | ||
| tab_id: Unique ID for the tab / pane element | ||
| language: Prism language identifier (default: 'json') | ||
|
|
||
| Returns: | ||
| HTML string for the tab pane | ||
| """ | ||
| return ( | ||
| # ── Tab pane ──────────────────────────────────────────────────────── | ||
| f'<div role="tabpanel" class="tab-pane" id="{tab_id}">\n' | ||
| f'<div class="schema-tab-content" style="padding:1rem;">\n' | ||
| f'<h3>JSON Schema</h3>\n' | ||
| f'<p><a href="{schema_filename}" target="_blank" ' | ||
| f'class="btn btn-sm btn-outline-secondary">' | ||
| f'📄 Download {schema_filename}</a></p>\n' | ||
| f'<pre style="margin:0;padding:0;background:transparent;border:none;">' | ||
| f'<code id="{tab_id}-display" class="language-{language}" ' | ||
| f'style="border-radius:4px;max-height:600px;overflow-y:auto;' | ||
| f'font-size:0.85em;display:block;">Loading schema…</code>' | ||
| f'</pre>\n' | ||
| f'</div>\n' | ||
| # ── Load + highlight on tab activation ─────────────────────────────── | ||
| # fetch() uses a relative URL → always same-origin → no CORS issue. | ||
| # Syntax highlighting uses Prism.js only (no CDN dependency). | ||
| # Unregistered languages fall through to plain text gracefully. | ||
| f'<script>\n' | ||
| f'(function(){{\n' | ||
| f' function loadSchema(){{\n' | ||
| f' var el=document.getElementById("{tab_id}-display");\n' | ||
| f' if(!el||el.dataset.loaded)return;\n' | ||
| f' el.dataset.loaded="1";\n' | ||
| f' fetch("{schema_filename}")\n' | ||
| f' .then(function(r){{return r.json();}})\n' | ||
| f' .then(function(d){{\n' | ||
| f' var txt=JSON.stringify(d,null,2);\n' | ||
| f' el.textContent=txt;\n' | ||
| f' if(window.Prism&&Prism.languages["{language}"]){{\n' | ||
| f' setTimeout(function(){{el.innerHTML=Prism.highlight(txt,Prism.languages["{language}"],"{language}");}},0);\n' | ||
| f' }}\n' | ||
| f' }})\n' | ||
| f' .catch(function(e){{\n' | ||
| f' el.textContent="Error loading schema: "+e.message;\n' | ||
| f' }});\n' | ||
| f' }}\n' | ||
| f' var link=document.getElementById("{tab_id}-head");\n' | ||
| f' if(link){{\n' | ||
| f' link.addEventListener("shown.bs.tab",loadSchema);\n' | ||
| f' if(link.classList.contains("active")){{loadSchema();}}\n' | ||
| f' }}else{{\n' | ||
| f' document.addEventListener("DOMContentLoaded",loadSchema);\n' | ||
| f' }}\n' | ||
| f'}})();\n' | ||
| f'</script>\n' | ||
| f'</div>' | ||
| ) | ||
|
|
There was a problem hiding this comment.
_generate_schema_tab_pane_html() is currently unused (no call sites), and the docstring suggests a tab-pane structure that doesn’t match the inter-page nav-tabs approach used elsewhere in this PR. Either remove it, or use it in a code path that actually generates tab panes to avoid confusing/unused code.
| deployment domain. | ||
|
|
||
| ``Prism.highlightElement(el)`` is called when ``window.Prism`` is | ||
| available and the requested language grammar is registered. Languages | ||
| not registered in Prism (``Prism.languages[language]`` is falsy, e.g. | ||
| ``cql``) fall through to plain formatted text — no silent failure. | ||
|
|
||
| Other options considered and rejected: | ||
|
|
||
| - **highlight.js** — requires an external CDN request; may be blocked | ||
| by strict CSP on domains such as smart.who.int. | ||
| - **CodeMirror** — full interactive editor, 6× heavier; designed for | ||
| editing not read-only display. | ||
|
|
||
| If Prism is unavailable the JSON is still pretty-printed via | ||
| ``JSON.stringify(d, null, 2)`` — fully readable, just without colours. |
There was a problem hiding this comment.
In _generate_schema_tab_pane_html()’s docstring, it states that Prism.highlightElement(el) is called, but the implementation uses Prism.highlight(...) and assigns innerHTML directly. Please update the docstring to match the actual behavior to avoid misleading future changes/debugging.
| Updated HTML string, or None if the nav-tabs <ul> was not found | ||
| """ | ||
| try: | ||
| schema_page = f'{spec_name}.schema.json.html' |
There was a problem hiding this comment.
_inject_schema_as_new_tab() takes schema_filename but never uses it (the link is always built as {spec_name}.schema.json.html). Either drop the unused parameter, or use it to validate/derive the target so the signature reflects what the function actually needs.
| schema_page = f'{spec_name}.schema.json.html' | |
| # Prefer the provided schema filename when available, falling back to the | |
| # historical convention of {spec_name}.schema.json.html. | |
| if schema_filename: | |
| base_name = os.path.basename(schema_filename) | |
| if base_name.endswith('.html'): | |
| schema_page = base_name | |
| else: | |
| schema_page = f'{base_name}.html' | |
| else: | |
| schema_page = f'{spec_name}.schema.json.html' |
| - name: Fix output directory ownership for DAK post-processing | ||
| if: inputs.do_dak != 'false' && env.DAK_ENABLED == 'true' | ||
| run: | |
There was a problem hiding this comment.
This workflow input is declared as type: boolean, but the step condition compares it to the string 'false'. To avoid expression type-coercion edge cases (especially for workflow_call boolean inputs), prefer boolean expressions like if: inputs.do_dak && env.DAK_ENABLED == 'true' (and ideally apply consistently across the workflow).

_generate_schema_view_pagegenerates companion.schema.json.htmlwith Prism.js highlighting_build_fhir_restore_js()_FHIR_R4_JSON_FALLBACK_LINKS— 57-entry static map for JSON format pages(?:"|")for Prism HTML-encoded property namessudo chown -R "$USER:$USER" ./outputbefore post-processing${{ github.head_ref || github.ref_name }}${{ github.workflow }}-gh-pagesserializes all buildscancel-in-progress: falseso queued builds are not cancelledOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.