Skip to content

Commit

Permalink
feat(markdown): show id and status in header
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Dec 4, 2019
1 parent 90a9a8e commit 08e1923
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
15 changes: 13 additions & 2 deletions lib/formatInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,23 @@ function formatInfo({ extension }) {
return schema.definitions !== undefined || schema['meta:extensible'] === true;
}

function isidentifiable(schema) {
if (!schema.properties) {
return 'undefined';
}
if (schema.properties['@id'] && schema.properties['@id'].type === 'string' && schema.properties['@id'].format === 'uri') {
return 'true';
} else {
return 'false';
}
}

function formatmeta(schema) {
return {
abstract: isabstract(schema.schema),
extensible: isextensible(schema.schema),
status: undefined,
identifiable: undefined,
status: schema.schema['meta:status'] || undefined,
identifiable: isidentifiable(schema.schema),
custom: undefined,
additional: undefined,
definedin: undefined
Expand Down
11 changes: 8 additions & 3 deletions lib/markdownBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ function build({ header, links = {} }) {
name: 'status',
title: 'Status',
undefinedlabel: 'Unknown status',
truelabel: 'Yes',
falselabel: 'No',
deprecatedlabel: 'Deprecated',
stablelabel: 'Stable',
stabilizinglabel: 'Stabilizing',
experimentallabel: 'Experimental',
},
{
name: 'identifiable',
Expand Down Expand Up @@ -93,7 +95,10 @@ function build({ header, links = {} }) {
(prop) => {
// this is a linked property

if (schema.meta && schema.meta[prop.name] && schema.meta[prop.name].link) {
if (schema.meta &&
schema.meta[prop.name] &&
typeof schema.meta[prop.name] !== 'object' &&
typeof schema.meta[prop.name].link === 'string') {
return tableCell(link(schema.meta[prop.name].link, '', text(schema.meta[prop.name].text)));
}
const value = schema.meta ? schema.meta[prop.name] : undefined;
Expand Down

0 comments on commit 08e1923

Please sign in to comment.