mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-27 16:14:08 +03:00
Display descriptions as GFM (closes #2)
This commit is contained in:
parent
1f3cd3d85b
commit
90f304304c
|
@ -1,5 +1,5 @@
|
||||||
<h1>{{data.title}} ({{data.version}})</h1>
|
<h1>{{data.title}} ({{data.version}})</h1>
|
||||||
<p *ng-if="data.description"> {{data.description}} </p>
|
<p *ng-if="data.description" inner-html="{{data.description | marked}}"> </p>
|
||||||
<p>
|
<p>
|
||||||
<!-- TODO: create separate components for contact and license ? -->
|
<!-- TODO: create separate components for contact and license ? -->
|
||||||
<span *ng-if="data.contact"> Contact:
|
<span *ng-if="data.contact"> Contact:
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
<span class="http-method" [ng-class]="data.method">{{data.method}}</span>
|
<span class="http-method" [ng-class]="data.method">{{data.method}}</span>
|
||||||
<span class="path">{{data.path}}</span>
|
<span class="path">{{data.path}}</span>
|
||||||
</h3>
|
</h3>
|
||||||
<p *ng-if="data.methodInfo.description" class="method-description">
|
<p *ng-if="data.methodInfo.description" class="method-description"
|
||||||
{{data.methodInfo.description}}
|
inner-html="{{data.methodInfo.description | marked}}">
|
||||||
</p>
|
</p>
|
||||||
<br>
|
<br>
|
||||||
<params-list pointer="{{pointer}}/parameters"> </params-list>
|
<params-list pointer="{{pointer}}/parameters"> </params-list>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<tr *ng-for="#param of data.params">
|
<tr *ng-for="#param of data.params">
|
||||||
<!--<div class="param">-->
|
<!--<div class="param">-->
|
||||||
<td class="param-name">{{param.name}}</td>
|
<td class="param-name">{{param.name}}</td>
|
||||||
<td class="param-description">{{param.description}}</td>
|
<td class="param-description" inner-html="{{param.description | marked}}"></td>
|
||||||
<td>
|
<td>
|
||||||
<span class="type" [ng-class]="param.type">{{param.type}}</span>
|
<span class="type" [ng-class]="param.type">{{param.type}}</span>
|
||||||
</td>
|
</td>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<!-- in-body parameter -->
|
<!-- in-body parameter -->
|
||||||
<tr class="param body-param" *ng-if="data.bodyParam">
|
<tr class="param body-param" *ng-if="data.bodyParam">
|
||||||
<td class="param-name">{{data.bodyParam.name}}</td>
|
<td class="param-name">{{data.bodyParam.name}}</td>
|
||||||
<td class="param-description">{{data.bodyParam.description}}</td>
|
<td class="param-description" inner-html="{{data.bodyParam.description | marked}}"></td>
|
||||||
<td>
|
<td>
|
||||||
<schema class="body-schema param-type" pointer="{{data.bodyParam.pointer}}/schema">
|
<schema class="body-schema param-type" pointer="{{data.bodyParam.pointer}}/schema">
|
||||||
</schema>
|
</schema>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ng-for="#response of data.responses">
|
<tr *ng-for="#response of data.responses">
|
||||||
<td>{{response.code}}</td>
|
<td>{{response.code}}</td>
|
||||||
<td>{{response.description}}</td>
|
<td inner-html="{{response.description | marked}}"></td>
|
||||||
<td>
|
<td>
|
||||||
<schema *ng-if="response.schema" class="schema type" pointer="{{response.pointer}}/schema">
|
<schema *ng-if="response.schema" class="schema type" pointer="{{response.pointer}}/schema">
|
||||||
</schema>
|
</schema>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2';
|
||||||
import {SchemaManager} from '../utils/SchemaManager';
|
import {SchemaManager} from '../utils/SchemaManager';
|
||||||
import {JsonPointerEscapePipe} from '../utils/pipes';
|
import {JsonPointerEscapePipe} from '../utils/pipes';
|
||||||
import {JsonPointer} from '../utils/JsonPointer';
|
import {JsonPointer} from '../utils/JsonPointer';
|
||||||
|
import {MarkedPipe} from '../utils/pipes';
|
||||||
|
|
||||||
// common inputs for all components
|
// common inputs for all components
|
||||||
let commonInputs = ['pointer']; // json pointer to the schema chunk
|
let commonInputs = ['pointer']; // json pointer to the schema chunk
|
||||||
|
@ -32,7 +33,7 @@ function safeConcat(a, b) {
|
||||||
export function RedocComponent(options) {
|
export function RedocComponent(options) {
|
||||||
let inputs = safeConcat(options.inputs, commonInputs);
|
let inputs = safeConcat(options.inputs, commonInputs);
|
||||||
let directives = safeConcat(options.directives, CORE_DIRECTIVES);
|
let directives = safeConcat(options.directives, CORE_DIRECTIVES);
|
||||||
let pipes = safeConcat(options.pipes, [JsonPointerEscapePipe]);
|
let pipes = safeConcat(options.pipes, [JsonPointerEscapePipe, MarkedPipe]);
|
||||||
|
|
||||||
return function decorator(target) {
|
return function decorator(target) {
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,19 @@
|
||||||
|
|
||||||
import {Pipe} from 'angular2/angular2';
|
import {Pipe} from 'angular2/angular2';
|
||||||
import {JsonPointer} from './JsonPointer';
|
import {JsonPointer} from './JsonPointer';
|
||||||
|
import marked from 'marked';
|
||||||
|
|
||||||
|
marked.setOptions({
|
||||||
|
renderer: new marked.Renderer(),
|
||||||
|
gfm: true,
|
||||||
|
tables: true,
|
||||||
|
breaks: false,
|
||||||
|
pedantic: false,
|
||||||
|
sanitize: true,
|
||||||
|
smartLists: true,
|
||||||
|
smartypants: false
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
@Pipe({
|
@Pipe({
|
||||||
name: 'keys'
|
name: 'keys'
|
||||||
|
@ -29,3 +42,13 @@ export class JsonPointerEscapePipe {
|
||||||
return JsonPointer.escape(str);
|
return JsonPointer.escape(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'marked'
|
||||||
|
})
|
||||||
|
export class MarkedPipe {
|
||||||
|
transform(str) {
|
||||||
|
if (!str) return str;
|
||||||
|
return marked(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user