Difference between revisions of "FHIR IG publisher templates"

From HL7Wiki
Jump to navigation Jump to search
Line 167: Line 167:
 
This event is called once all the resources have been loaded, processed/validated etc, and then all the resources that are going to be produced have been written into the \temp folder (in whatever formats specified by the reloaded IG resource), and the IG publisher is about to produce html fragments.  
 
This event is called once all the resources have been loaded, processed/validated etc, and then all the resources that are going to be produced have been written into the \temp folder (in whatever formats specified by the reloaded IG resource), and the IG publisher is about to produce html fragments.  
  
The ant script may generate it's own HTML content, or alter the jekyll template data files etc. The working ImplementationGuide resource is available at \template\ig-working.xml|json (can no longer be modified)
+
The ant script may generate it's own HTML content, or alter the jekyll template data files etc.  
 +
 
 +
The working ImplementationGuide resource is available at \template\ig-working.xml|json. This can be modified by the template by producing ig-updated.xml or ig-updated.json in \template. If the IG is updated, the following rules apply:
 +
 
 +
* the list of resources cannot be changed (though it can be re-ordered, and information about the resources can be changed)
 +
* other than this, the definition can be changed, and the manifest.page, manifest.image, and manifest.other lists can be changed.
 +
* all other changes to the IG will be ignored
 +
 
 +
Note that to help the the template process the script, additional information about the resource is provided in the extension http://tools.fhir.org/StructureDefinition/resource-information. This extension will be removed by the IG publisher after the onGenerate event is called.
  
 
The following additional Ant properties are set for this event:
 
The following additional Ant properties are set for this event:
 +
 +
(none)
  
 
=== onJekyll ===
 
=== onJekyll ===

Revision as of 08:04, 20 June 2019

FHIR IG templates are used by the FHIR IG Publishing tool when publishing FHIR Implementation Guides. The templates control:

  • the look and feel of the published IG
  • the way the resources are expressed as pages
  • how users navigate around the pages

From the point of view of an IG Author, the IG template consists of a package they reference, and documentation that describes how the author writes their own narrative and fits that into the pages described by the template.

Known IG templates

To use a template, you specify the 'template' parameter in the IG. You can nominate the official packageId for a template (package ids in the HL7 namespace are assigned by the FHIR product director, and other wise you can make up your own)

List of known IGs:

package id description documentation source
fhir.test.template a test template the generates all the kinds of things that can be published Todo http://github.com/fhir/test-template
hl7.fhir.template the standard template for HL7 published implementation guides ? http://github.com/hl7/fhir-ig-template
hl7.fhir.au.template the standard template for HL7 Australia published implementation guides ? http://github.com/hl7-au/fhir-ig-template
ihe.fhir.template the standard template for IHE-published implementation guides ? ?

Note to template authors: you can add your template to this table, as a url + documentation, but only the FHIR product director can make a particular template trusted (see below).

Authoring IG templates

The information below is for authors of templates and is highly technical. It should only be used by template authors.

A template contains 5 kinds of artifacts:

Publishing Templates

Any template should be authored in a Github repository, and registered with the IG Auto-publisher - see [Auto-IG-Publisher Documentation]. Whenever commits are pushed to GitHub, a new 'current' version of the template will be published.

To do a milestone release - that is, one that authors can refer to by version, create a branch in github with the correct version stated in the package/package.json file, and send the tag id as a request to the FHIR product Director

File layout of a Template

The template lives in a github location somewhere. There are 3 important folders in the template package:

  • package - must contain a file package.json, with contents as below.
  • content - contains the content that will go straight into the IG build folder
  • scripts - contains the template content - scripts, etc. Must have a template.ini file (see below)

Note: other folders can exist and contain whatever the author wants- they are ignored by the FHIR IG publisher tooling.

When an IG template is used:

  • the files in the template folder will be extracted into a \template directory in the root folder that the IG Publisher is running in
  • the files in content folder will be extracted into the \temp directory in the root folder that the IG publisher is running in (Jekyll runs in this folder so they are provided to Jekyll as published content directly)

package\package.json

Use this as a template:

{
  "name": "[package-id]",
  "version": "[ver]",
  "type": "fhir.template",
  "license": "[license]",
  "description": "[description]",
  "author": "[url]",
  "canonical" : "[canonical]"
}

Notes:

  • [package-id] must be chosen in accordance with the FHIR package naming convention
  • [ver] is under manual control of the author. Use semver. You will have to update the version to get IG publisher to pick up new versions
  • [license] - license of author's choice. Use CC0-1.0 for HL7 published templates
  • [description] - whatever
  • [url] - project website (e.g. contact details)
  • [canonical] - For IGs authored in GitHub, the GitHub repository URL.

config.json

This file controls the functionality of the template. It has the following entries (all of which are optional):

{ 
  "defaults" : { .. todo.. },
  "scripts" : {
    "onLoad" : "[filename]",
    "onGenerate" : "[filename]",
    "onJekyll" : "[filename]",
    "onCheck" : "[filename]"
  }
 }

scripts

Entry should only be present if the script is in use. file name is relative to the root of the template

  • onLoad: ant script that runs after the IG resource has been loaded - it can edit the IG resource
  • onGenerate: an ant script that runs before any html is generated
  • onJekyll: an ant script that runs before running Jekyll
  • onCheck: an ant script that runs before checking Jekyll output

Script Events

Notes:

  • The Ci-Build (IG auto-publisher) will only accept templates from trusted templates. To get a template to be trusted, talk to the FHIR Product Director
  • if you run the IGPublisher jar with the parameter -debug, it will stop and wait for a prompt at the script execution points (before and after running the ant script) to allow template authors to inspect the content of the folders
  • the working diretory when the ant script runs is the base folder for the IG Publisher, not the folder containing the ant scripts
  • the special IG resource (for on-load) will always be in R4 version; all the other resources will be in whatever version is specified in the IG
  • The build file should be able to run offline (e.g. only depend on content in the template and from the IG publisher)
  • the ant scripts can run whatever is supported on windows, linux, and osx. Known supported languages:
 * javascript
 * xslt

The following Ant properties are set for all events:

  • ig.root - the root directory of the IG being processed
  • ig.temp - the temp directory where the jekyll source is being assembled
  • ig.template - the source folder for the template contnet
  • ig.scripts - the source folder for the scripts (the template scripts folder)
  • ig.source - the path to "ig-working." - append either xml or json to get the appropriate file

onLoad

This event exists for a very specific purpose: to allow the template to alter the IG resource itself. At the point that this ant script executes, the following actions have been done:

  • the hase specification package has been loaded
  • the IG resource has been read
  • the template has been located and extracted as described above
  • the IG resource has been written to ig-working.xml and ig-working.json in \template
  • the ant script must produce the file ig-updated.xml or ig-updated.json in \template
  • this file will be re-loaded and used as the working IG resource for the rest of the build

The expectation is that the template will update the pages / resources (an maybe the parameters) from after examining the other folders. Changing other files is not supported for this event

Notes:

  • the Implementation Guide is always in R5 format.
  • the xml dest is checked first and then the json dest - if both are produced, the xml one will be used

The following additional Ant properties are set for this event:

  • ig.dest - the path to the "ig-updated." - append either xml or json to get the appropriate file

onGenerate

This event is called once all the resources have been loaded, processed/validated etc, and then all the resources that are going to be produced have been written into the \temp folder (in whatever formats specified by the reloaded IG resource), and the IG publisher is about to produce html fragments.

The ant script may generate it's own HTML content, or alter the jekyll template data files etc.

The working ImplementationGuide resource is available at \template\ig-working.xml|json. This can be modified by the template by producing ig-updated.xml or ig-updated.json in \template. If the IG is updated, the following rules apply:

  • the list of resources cannot be changed (though it can be re-ordered, and information about the resources can be changed)
  • other than this, the definition can be changed, and the manifest.page, manifest.image, and manifest.other lists can be changed.
  • all other changes to the IG will be ignored

Note that to help the the template process the script, additional information about the resource is provided in the extension http://tools.fhir.org/StructureDefinition/resource-information. This extension will be removed by the IG publisher after the onGenerate event is called.

The following additional Ant properties are set for this event:

(none)

onJekyll

This event is called once all the html fragments have been produced, and the IG publisher is about to call Jekyll. The \temp folder is ready to go.

The ant script may generate it's own HTML fragments, or alter the jekyll template data files etc. The working ImplementationGuide resource is available at \template\ig-working.xml|json (can no longer be modified)

onCheck

This event is called once Jekyll has finished running, and the output folder is populated, but before the broken ink & security checks are run

The ant script may modify the content in \output. The working ImplementationGuide resource is available at \template\ig-working.xml|json (can no longer be modified)