Socket
Socket
Sign inDemoInstall

koa-docs

Package Overview
Dependencies
9
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.0 to 0.8.1

2

example/routes/pets.js

@@ -81,3 +81,3 @@ 'use strict';

},
output: t.array().items(Pet)
output: t.array().items(Pet.requiredKeys('id', 'status'))
},

@@ -84,0 +84,0 @@ *handler () {

@@ -27,2 +27,4 @@ 'use strict';

theme: 'simplex', // Any theme from www.bootswatch.com
groups: [

@@ -35,5 +37,7 @@ // Provide the routes to the koa-api-docs for rendering

extendedDescription: `
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a
diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac
quam viverra nec consectetur ante hendrerit.
Markdown is supported in the \`extendedDescription\` fields so
it is an ideal place to add additional information while leaving
the \`friendlyName\` and \`description\` fields concise. This allows
easier navigation and better collapsing of groups and routes.
* Donec et mollis dolor.

@@ -40,0 +44,0 @@ * Praesent et diam eget libero egestas mattis sit amet vitae augue.

{
"name": "koa-docs",
"version": "0.8.0",
"version": "0.8.1",
"description": "An automatic documentation generator for koa.js APIs ",

@@ -5,0 +5,0 @@ "main": "src/main.js",

@@ -8,3 +8,3 @@ # koa-docs

![Screenshot](http://i.imgur.com/jUcraT6.png)
![Screenshot](http://i.imgur.com/jv1k4g3.png)

@@ -26,2 +26,5 @@ ## Install

theme: 'simplex', // Specify a theme from www.bootswatch.com;
// default is un-themed bootstrap
groups: [

@@ -75,3 +78,3 @@ { groupName: 'Pets', routes: [/* ... route specs ... */] },

* [x] Ability to collapse/expand routes and groups
* [ ] Ability to switch themes and make default theme configurable
* [x] Ability to switch themes and make default theme configurable
* [ ] More descriptive type descriptions for arrays and nested objects

@@ -78,0 +81,0 @@ * [ ] Create separate section for models (joi objects that have a label)

@@ -36,3 +36,3 @@ 'use strict';

function routeDescription (route, className) {
function routeDescription (route) {
const meta = route.meta || {};

@@ -42,3 +42,3 @@ const desc = meta.description;

return m('div.panel-body', { className }, [
return m('div.panel-body', [
m('p', routeInfo(route.method, route.path)),

@@ -50,3 +50,3 @@ !desc ? '' : m('p', desc),

function routeFooter (route, className) {
function routeFooter (route) {
const handler = stripIndent(` ${route.handler.toString()}`);

@@ -59,3 +59,3 @@

return m('div.panel-footer', { className }, [
return m('div.panel-footer', [
m('h5', { style: { margin: '1rem' } }, 'Implementation:'),

@@ -73,5 +73,7 @@ m('pre', { style }, handler)

routeHeading(route, collapseSelector),
routeDescription(route, collapseState),
routeParams(route, collapseState),
routeFooter(route, collapseState)
m('div', { className: collapseState }, [
routeDescription(route),
routeParams(route),
routeFooter(route)
])
]);

@@ -78,0 +80,0 @@ }

@@ -23,3 +23,3 @@ 'use strict';

<ul class="dropdown-menu switch-theme">
<li><a href="#" theme="bootstrap">Default</a></li>
<li><a href="#" theme="bootstrap">Bootstrap</a></li>
<li role="separator" class="divider"></li>

@@ -26,0 +26,0 @@ <li><a href="#" theme="cerulean">Cerulean</a></li>

@@ -6,12 +6,13 @@ 'use strict';

module.exports = function routeParams (route, className) {
module.exports = function routeParams (route) {
return [
paramsTable(route.validate, 'header', { className }),
paramsTable(route.validate, 'query', { className }),
paramsTable(route.validate, 'params', { className }),
paramsTable(route.validate, 'body', { className })
paramsTable(route.validate, 'header'),
paramsTable(route.validate, 'query'),
paramsTable(route.validate, 'params'),
paramsTable(route.validate, 'body'),
paramsTable(route.validate, 'output')
];
};
function paramsTable (validations, type, opts) {
function paramsTable (validations, type) {
if (!validations || !validations.hasOwnProperty(type)) return [];

@@ -21,18 +22,12 @@

const className = opts.className || '';
const style = {
borderTop: '1px solid #eee',
borderBottom: '1px solid #eee'
};
return [
// Heading before the table (i.e Body, Params, etc)
paramsHeader(schema, type, validations, opts),
paramsHeader(schema, type, validations),
m('table.table.table-bordered.table-striped', { style, className }, [
m('table.table.table-striped', [
m.trust(`
<colgroup>
<col span="1" style="width: 25%;">
<col span="1" style="width: 20%;">
<col span="1" style="width: 15%;">
<col span="1" style="width: 60%;">
<col span="1" style="width: 65%;">
</colgroup>

@@ -48,3 +43,3 @@ <thead>

paramsTableBody(schema, type, validations)
getItems(schema).map(paramsTableBody)
])

@@ -54,7 +49,7 @@ ];

function paramsHeader (schema, type, validations, opts) {
function paramsHeader (schema, type, validations) {
const bodyType = validations.type;
const label = get(schema, '_settings.language.label');
const label = isArray(schema) ? arrayLabel(schema) : itemLabel(schema);
return m('h4', { style: { margin: '1rem' }, className: opts.className }, [
return m('h4', { style: { margin: '1rem' } }, [
// Capitalize

@@ -95,1 +90,20 @@ type.slice(0, 1).toUpperCase() + type.slice(1),

}
function isArray (schema) {
return schema._type === 'array';
}
function getItems (schema) {
if (!isArray(schema)) return [schema];
return get(schema, '_inner.items', []);
}
function itemLabel (schema) {
return get(schema, '_settings.language.label', '');
}
function arrayLabel (schema) {
if (!isArray(schema)) return '';
const items = getItems(schema).map(itemLabel);
return `Array [${items}]`;
}

@@ -25,2 +25,6 @@ 'use strict';

module.exports = function renderTemplate (opts) {
const theme = opts.theme && opts.theme !== 'bootstrap' ?
swatch(`${opts.theme}/bootstrap.min.css`) :
bootstrap('css/bootstrap-theme.min.css');
return [

@@ -44,3 +48,3 @@ m.trust(doctype),

rel: 'stylesheet',
href: swatch('paper/bootstrap.min.css')
href: theme
}),

@@ -47,0 +51,0 @@ m.trust(`<style>${css}</style>`)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc