Skip to content

Latest commit

 

History

History
1420 lines (1190 loc) · 51.7 KB

api.md

File metadata and controls

1420 lines (1190 loc) · 51.7 KB

API-Documentation

This page describes the API of this Bootprint-module

Templates

index.html

Source file bootprint-base @ 2.0.0-rc.2 / handlebars/templates/index.html.hbs
Structure

index.htmlDefault template for rendering the HTML-page.
│     ...
├─┬ base/html-head
│ │ This partial is rendered into the ``-tag of ...
│ ├── base/title
│ │   This partial is rendered into the HTML-title in th...
│ └── base/html-head-extraThis partial is added inside the -tag, after...
├─┬ base/header
│ │ Renders the part at the top of the page, which is ...
│ └── json-schema/navbarRenders the navigation bar at the top of the page
│     ...
├─┬ base/body
│ │ Renders the main-schema as panel and the sub-schem...
│ ├─┬ json-schema/schema
│ │ │ Renders a json-schema. This is the entry-point of ...
│ │ ├── json-schema/ref
│ │ │   Renders a single json-reference
│ │ │   @this {object} the...
│ │ ├── json-schema/type
│ │ │   Render the "type" keyword of a json-schema
│ │ │   @this {...
│ │ ├─┬ json-schema/string
│ │ │ │ Render the string-specific keywords of a json-sche...
│ │ │ └── json-schema/util/regex
│ │ │     Renders a regular express (e.g. for `patternProper...
│ │ ├── json-schema/number
│ │ │   Render the number-specific keywords of a json-sche...
│ │ ├─┬ json-schema/object
│ │ │ │ Render the object-specific keyword of a json-schem...
│ │ │ ├── json-schema/schema
│ │ │ │   (🔁 cycle detected) 
│ │ │ └── json-schema/util/regex
│ │ │     Renders a regular express (e.g. for `patternProper...
│ │ ├─┬ json-schema/enum
│ │ │ │ Render the enum keyword of a json-schema
│ │ │ │ @this {ob...
│ │ │ └── json-schema/util/value
│ │ │     Renders a single default, enum or const value
│ │ │     @thi...
│ │ ├─┬ json-schema/const
│ │ │ │ Render the "const" keyword of a json-schema
│ │ │ │ @this ...
│ │ │ └── json-schema/util/value
│ │ │     Renders a single default, enum or const value
│ │ │     @thi...
│ │ ├─┬ json-schema/array
│ │ │ │ Renders the array-specific keywords of a json-sche...
│ │ │ └── json-schema/schema
│ │ │     (🔁 cycle detected) 
│ │ ├─┬ json-schema/allOf
│ │ │ │ Render the allOf keyword of a json-schema
│ │ │ │ @this {o...
│ │ │ └── json-schema/schema
│ │ │     (🔁 cycle detected) 
│ │ ├─┬ json-schema/oneOf
│ │ │ │ Render the oneOf keyword of a json-schema
│ │ │ │ @this {o...
│ │ │ └── json-schema/schema
│ │ │     (🔁 cycle detected) 
│ │ ├─┬ json-schema/anyOf
│ │ │ │ Render the anyOf keyword of a json-schema
│ │ │ │ @this {o...
│ │ │ └── json-schema/schema
│ │ │     (🔁 cycle detected) 
│ │ ├─┬ json-schema/not
│ │ │ │ Render the not keyword of a json-schema
│ │ │ │ @this {obj...
│ │ │ └── json-schema/schema
│ │ │     (🔁 cycle detected) 
│ │ ├─┬ json-schema/examples-default
│ │ │ │ Render the "examples" and "default" keywords of a ...
│ │ │ ├─┬ json-schema/draft-04/default
│ │ │ │ │ Render default values as in draft-04 (without "exa...
│ │ │ │ └── json-schema/util/value
│ │ │ │     Renders a single default, enum or const value
│ │ │ │     @thi...
│ │ │ └── json-schema/util/value
│ │ │     Renders a single default, enum or const value
│ │ │     @thi...
│ │ └── json-schema/format
│ │     Render the "format" keyword of a json-schema
│ │     @this...
│ └─┬ json-schema/definitions
│   │ Renders the defintiions-property of the main-schem...
│   └─┬ json-schema/schema
│     │ Renders a json-schema. This is the entry-point of ...
│     ├── json-schema/ref
│     │   Renders a single json-reference
│     │   @this {object} the...
│     ├── json-schema/type
│     │   Render the "type" keyword of a json-schema
│     │   @this {...
│     ├─┬ json-schema/string
│     │ │ Render the string-specific keywords of a json-sche...
│     │ └── json-schema/util/regex
│     │     Renders a regular express (e.g. for `patternProper...
│     ├── json-schema/number
│     │   Render the number-specific keywords of a json-sche...
│     ├─┬ json-schema/object
│     │ │ Render the object-specific keyword of a json-schem...
│     │ ├── json-schema/schema
│     │ │   (🔁 cycle detected) 
│     │ └── json-schema/util/regex
│     │     Renders a regular express (e.g. for `patternProper...
│     ├─┬ json-schema/enum
│     │ │ Render the enum keyword of a json-schema
│     │ │ @this {ob...
│     │ └── json-schema/util/value
│     │     Renders a single default, enum or const value
│     │     @thi...
│     ├─┬ json-schema/const
│     │ │ Render the "const" keyword of a json-schema
│     │ │ @this ...
│     │ └── json-schema/util/value
│     │     Renders a single default, enum or const value
│     │     @thi...
│     ├─┬ json-schema/array
│     │ │ Renders the array-specific keywords of a json-sche...
│     │ └── json-schema/schema
│     │     (🔁 cycle detected) 
│     ├─┬ json-schema/allOf
│     │ │ Render the allOf keyword of a json-schema
│     │ │ @this {o...
│     │ └── json-schema/schema
│     │     (🔁 cycle detected) 
│     ├─┬ json-schema/oneOf
│     │ │ Render the oneOf keyword of a json-schema
│     │ │ @this {o...
│     │ └── json-schema/schema
│     │     (🔁 cycle detected) 
│     ├─┬ json-schema/anyOf
│     │ │ Render the anyOf keyword of a json-schema
│     │ │ @this {o...
│     │ └── json-schema/schema
│     │     (🔁 cycle detected) 
│     ├─┬ json-schema/not
│     │ │ Render the not keyword of a json-schema
│     │ │ @this {obj...
│     │ └── json-schema/schema
│     │     (🔁 cycle detected) 
│     ├─┬ json-schema/examples-default
│     │ │ Render the "examples" and "default" keywords of a ...
│     │ ├─┬ json-schema/draft-04/default
│     │ │ │ Render default values as in draft-04 (without "exa...
│     │ │ └── json-schema/util/value
│     │ │     Renders a single default, enum or const value
│     │ │     @thi...
│     │ └── json-schema/util/value
│     │     Renders a single default, enum or const value
│     │     @thi...
│     └── json-schema/formatRender the "format" keyword of a json-schema
│         @this...
├── base/footerThis partial is displayed at the bottom of the HTM...
└── base/javascript-libs
    This partial is rendered below the `footer`-partia...
Default template for rendering the HTML-page.
    It can be replaced by another template if needed. However, in the average case,
    it should be left unmodified since it calls partials that can be overridden instead.

    The template includes the result of the Less-compiler (`main.css`)
    and places the other partials (`base/header`, `base/body` and `base/footer`)
    above, within and below a `div.container`-element.

    @public

Partials

base/body

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/base/body.hbs
Uses partials json-schema/schema, json-schema/definitions
Used by index.html
Renders the main-schema as panel and the sub-schemas below.
This partial can be overridden if json-schema is only part of
what should be displayed.
@public

base/footer

Source file bootprint-base @ 2.0.0-rc.2 / handlebars/partials/base/footer.hbs
Used by index.html
This partial is displayed at the bottom of the HTML-body.
    It is empty and can be overridden to include custom content in
    the Bootprint-result.

    @param {object} $context$ the whole input data
    @public

base/header

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/base/header.hbs
Uses partials json-schema/navbar
Used by index.html
Renders the part at the top of the page, which is the navigation bar by default
This partial can be overridden in order to remove or change the navigation or
display additional data

@public

base/html-head-extra

Source file bootprint-base @ 2.0.0-rc.2 / handlebars/partials/base/html-head-extra.hbs
Used by base/html-head
This partial is added inside the <head>-tag, after the
    other declarations of the "base/html-head"-partial.

    @param {object} $context$ the whole input data
    @public

base/html-head

Source file bootprint-base @ 2.0.0-rc.2 / handlebars/partials/base/html-head.hbs
Uses partials base/title, base/html-head-extra
Used by index.html
This partial is rendered into the `<head>`-tag of the page.
    Additional tags can be placed in the partial `base/html-head-extra.hbs`.

    This partial can also be overridden to replace its contents, but beware
    that changes to this file may happen without incrementing the major version.
    @access private

base/javascript-libs

Source file bootprint-base @ 2.0.0-rc.2 / handlebars/partials/base/javascript-libs.hbs
Used by index.html
This partial is rendered below the `footer`-partial of the page. You can include
    a javascript-bundle here that can be created by using `customize-engine-uglify`

base/title

Source file bootprint-base @ 2.0.0-rc.2 / handlebars/partials/base/title.hbs
Used by base/html-head
This partial is rendered into the HTML-title in the `<head>`-tag of the page.
    It can be overridden in order to display a custom title.

json-schema/allOf

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/allOf.hbs
Uses partials json-schema/schema
Used by json-schema/schema
Render the allOf keyword of a json-schema
@this {object} the json-schema

json-schema/anyOf

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/anyOf.hbs
Uses partials json-schema/schema
Used by json-schema/schema
Render the anyOf keyword of a json-schema
@this {object} the json-schema

json-schema/array

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/array.hbs
Uses partials json-schema/schema, json-schema/schema, json-schema/schema, json-schema/schema
Used by json-schema/schema
Renders the array-specific keywords of a json-schema
@this {object} the json-schema

json-schema/const

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/const.hbs
Uses partials json-schema/util/value
Used by json-schema/schema
Render the "const" keyword of a json-schema
@this {object} the json-schema

json-schema/definitions

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/definitions.hbs
Uses partials json-schema/schema
Used by base/body
Renders the defintiions-property of the main-schema
@this {object} the json-schema

json-schema/draft-04/default

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/draft-04/default.hbs
Uses partials json-schema/util/value
Used by json-schema/examples-default
Render default values as in draft-04 (without "examples")

json-schema/enum

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/enum.hbs
Uses partials json-schema/util/value
Used by json-schema/schema
Render the enum keyword of a json-schema
@this {object} the json-schema

json-schema/examples-default

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/examples-default.hbs
Uses partials json-schema/draft-04/default, json-schema/util/value, json-schema/util/value
Used by json-schema/schema
Render the "examples" and "default" keywords of a json-schema
@this {object} the json-schema

json-schema/format

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/format.hbs
Used by json-schema/schema
Render the "format" keyword of a json-schema
@this {object} the json-schema

json-schema/navbar

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/navbar.hbs
Used by base/header
Renders the navigation bar at the top of the page
@this {object} the json-schema

json-schema/not

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/not.hbs
Uses partials json-schema/schema
Used by json-schema/schema
Render the not keyword of a json-schema
@this {object} the json-schema

json-schema/number

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/number.hbs
Used by json-schema/schema
Render the number-specific keywords of a json-schema
@this {object} the json-schema

json-schema/object

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/object.hbs
Uses partials json-schema/schema, json-schema/util/regex, json-schema/schema, json-schema/schema, json-schema/schema, json-schema/schema
Used by json-schema/schema
Render the object-specific keyword of a json-schema
@this {object} the json-schema

json-schema/oneOf

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/oneOf.hbs
Uses partials json-schema/schema
Used by json-schema/schema
Render the oneOf keyword of a json-schema
@this {object} the json-schema

json-schema/ref

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/ref.hbs
Used by json-schema/schema
Renders a single json-reference
@this {object} the object containing the $ref-property

json-schema/schema

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/schema.hbs
Uses partials json-schema/ref, json-schema/type, json-schema/string, json-schema/number, json-schema/object, json-schema/enum, json-schema/const, json-schema/array, json-schema/allOf, json-schema/oneOf, json-schema/anyOf, json-schema/not, json-schema/examples-default, json-schema/format
Used by base/body, json-schema/allOf, json-schema/anyOf, json-schema/array, json-schema/array, json-schema/array, json-schema/array, json-schema/definitions, json-schema/not, json-schema/object, json-schema/object, json-schema/object, json-schema/object, json-schema/object, json-schema/oneOf
Renders a json-schema. This is the entry-point of the schema.
@this {object} the json-schema

json-schema/string

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/string.hbs
Uses partials json-schema/util/regex
Used by json-schema/schema
Render the string-specific keywords of a json-schema
@this {object} the json-schema

json-schema/type

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/type.hbs
Used by json-schema/schema
Render the "type" keyword of a json-schema
@this {object} the json-schema

json-schema/util/regex

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/util/regex.hbs
Used by json-schema/object, json-schema/string
Renders a regular express (e.g. for `patternProperties` and `pattern`)

json-schema/util/section

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/util/section.hbs
Uses partials @partial-block
Helper partial to render a section for a keyword (items, type, properties etc).
The partial is used as block-partial and the @partial-block is the contents of the
section.

@param {string} sections a coma-separated list of section names (i.e. items, additionalItems)
@param {string} title a title for the restrictions
@public

json-schema/util/value

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/util/value.hbs
Used by json-schema/const, json-schema/draft-04/default, json-schema/enum, json-schema/examples-default, json-schema/examples-default, json-schema/util/values
Renders a single default, enum or const value
@this {*} the value

json-schema/util/values

Source file bootprint-json-schema @ 2.0.0-rc.3 / handlebars/partials/json-schema/util/values.hbs
Uses partials json-schema/util/value
Render a list of example values
@this {*[]} the list of values

Helpers (bootprint-base)

(from [email protected]/handlebars/helpers.js )

helpers

Default Handlebars-helpers for bootprint-base

Kind: global variable

helpers.toUpperCase(value) ⇒ string

Converts a string to uppercase

Kind: static method of helpers
Returns: string - the uppercase string
Access: public

Param Type Description
value string the input string

helpers.eachSorted() ⇒ string

This block-helper can be used to iterate objects sorted by key. It behaves like the built-in {{#each ...}}-helper except that it can only be used for objects and the output is in a deterministic order (i.e. sorted).

Example template:

{{#eachSorted obj}}
   {{@index}} of {{@length}}: {{@key}}={{.}}
{{/eachSorted}}

With the data { b: 'another one', a: 'first' }, ignoring newlines and indents, this will output

1 of 2: a=first
2 of 2: b=another one

The helper will set the following @-values according to the Handlebars documentation: @first, @index, @key, @last, @length

Kind: static method of helpers
Access: public

helpers.equal(value1, value2) ⇒ boolean

Checks whether two values a equal as in value1 == value2 (not ===)

Kind: static method of helpers
Access: public

Param
value1
value2

helpers.md(`value`) ⇒ Handlebars.SafeString

Render a markdown-formatted text as HTML.

Kind: static method of helpers
Returns: Handlebars.SafeString - a Handlebars-SafeString containing the provieded markdown, rendered as HTML.
Access: public

Param Type Description
value string the markdown-formatted text
options.hash.stripParagraph boolean the marked-md-renderer wraps generated HTML in a <p>-tag by default. If this options is set to true, the <p>-tag is stripped.

helpers.ifeq(`v1`, `v2`)

Block helper that compares to values. The body is executed if both value equal. Example:

{{#ifeq value 10}}
   Value is 10
{{else}}
   Value is not 10
{{/ifeq}}

Kind: static method of helpers
Access: public

Param Type Description
v1 object the first value
v2 object the second value

helpers.json(value) ⇒ string

Converts a javascript-object into a stringified highlighted JSON-object

Kind: static method of helpers
Access: public

Param Type Description
value object the javascript object

helpers.ifcontains(array, object, options) ⇒ string

Executes the block, if an object is part of an array

Kind: static method of helpers
Access: public

Param Type Description
array Array.<object> the array
object object the javascript object
options object the Handlebars options

helpers.htmlId(value) ⇒ string

Replace all characters that may not be used in HTML id-attributes by '-'. There is still the restriction that IDs may only start with letters, which is not addressed by this helper.

Kind: static method of helpers
Returns: string - the value after replacement and escaping
Access: public

Param Type Description
value string the input value

Helpers (bootprint-json-schema)

(from [email protected]/handlebars/helpers/index.js )

helpers

Default Handlebars-helpers for bootprint-json-schema

Kind: global variable

helpers.json_schema__doclink(type, sectionName, options) ⇒ string | Handlebars.SafeString

Render a link to a json-schema docs section from the json-schema documentation. If the section does not exist, it is assumed to be a vendor extension. The mapping of names to section numbers can be found in the version-specific helper files.

Kind: static method of helpers
Returns: string | Handlebars.SafeString - a SafeString containing a link to the documentation or 'vender extension' if there is no section of the given name
Access: public

Param Type Description
type string the type of section (keywords, formats)
sectionName string the section name (e.g. items)
options object the Handlebars options

helpers.json_schema__if_version(...targetVersions)

Executes the helper-block, if the version matches any of the specified target versions

Kind: static method of helpers
Access: public

Param Type Description
...targetVersions string a list of schema-versions to match against (varargs)

helpers.json_schema__datatype(schema, types) ⇒ String

Returns the datatype of a schema as short formal string like array<string|integer>

Kind: static method of helpers
Returns: String - a string like array<string|integer>
Access: public

Param Type Description
schema object a json-schema
types string | Array.<string> one or more types of potentially multiple types in the schema that should be used right now.

helpers.json_schema__number_range(schema, options) ⇒ string

Return a string for the numeric range restriction of the given schema (as determined by minimum, maximum, exclusiveMinimum and exclusiveMaximum properties).

The implementation is dispatched to version-specific behavior because draft-04 and draft-05 differ from draft-06

Kind: static method of helpers
Returns: string - a string like 1 < x < 2 or x ≤ 5
Access: public

Param Type Description
schema object the current (sub-)schema
options object the Handlebars options

helpers.json_schema__definition_id(name) ⇒ string

Compute the element-id for a definition panel

Kind: static method of helpers
Returns: string - an id without invalid characters for HTML-ids
Access: public

Param Type Description
name string the name of the definition (the key within the definitions object)

helpers.json_schema__count_range([min], [max], singular, plural) ⇒ string | null

Returns a prose-description of a number of things (e.g. "at least one item", "2 to 5 items")

Kind: static method of helpers
Returns: string | null - a prose-description or null if there is no range
Access: public

Param Type Description
[min] number the lower bound
[max] number the upper bound
singular string the "thing" in it singular form
plural string the "thing" it its plural form

helpers.json_schema__subschema_name(url) ⇒ *

Extract then name of a subschema from a $ref property

Kind: static method of helpers
Access: public

Param Type
url string

helpers.json_schema__is_required(schema, propertyName) ⇒ boolean

Returns "true", if the given propertyName is among the required properties of a schema

Kind: static method of helpers
Returns: boolean - true, if the given propertyName is required
Access: public

Param Type Description
schema object the json-schema to check for required properties of
propertyName string the property the name of the property

helpers.json_schema__could_be_numeric() ⇒ boolean

Return true, if the type is numeric (integer or number) or could be numeric

The type could be numeric, if it is an array that includes number or integer, or if it is not specified.

Kind: static method of helpers
Returns: boolean - true, if the type could be numeric
this: {undefined|string|string[]}
Access: public

helpers.json_schema__could_be_of_type(type) ⇒ boolean

Return true, if the dataType of a schema could be a given type

This includes an undefined type property, an array type-property that includes the checke values and a string `type'-property that equals the checked value.

Kind: static method of helpers
Returns: boolean - true, if the type of the schema could be the parameter
Access: public

Param Type Description
type string the type to check the schema against

helpers.json_schema__split_coma(list) ⇒ Array.<string>

Splits a coma-separated list into an array.

This helper can be used as nested-helper for other helpers that expect arrays

Kind: static method of helpers
Returns: Array.<string> - the list items as array
Access: public

Param Type Description
list string a coma-separated list of strings

helpers.json_schema__is_array(value) ⇒ boolean

Returns true, if the value is an array

Kind: static method of helpers
Returns: boolean - true, if the value is an array
Access: public

Param Type Description
value * the value

helpers.json_schema__has_any(schema, ...keywords) ⇒ boolean

Checks, if the given schema contains any of the provided keywords (like "type" or "items")

Kind: static method of helpers
Returns: boolean - true, if any of the keywords exists in the schema
Access: public

Param Type Description
schema object a json-schema
...keywords string a list of keywords to check again

helpers.json_schema__enumerate(items) ⇒ string

Convert an array into a prose-enumeration

Kind: static method of helpers
Returns: string - a written enumeration (a,b and c)
Access: public

Param Type Description
items Array.<string> an array of strings (e.g. ['a','b','c'])

LessCSS

Main LessCSS-files

LessCSS include paths