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.9.0 to 0.9.3

2

package.json
{
"name": "koa-docs",
"version": "0.9.0",
"version": "0.9.3",
"description": "An automatic documentation generator for koa.js APIs ",

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

@@ -39,2 +39,4 @@ # koa-docs

routeHandlers: 'disabled', // Hide the route implementation code from docs
groups: [

@@ -63,2 +65,3 @@ { groupName: 'Pets', routes: [/* ... route specs ... */] },

- `version`: string representing api version; also displayed at top of the docs
- `routeHandlers`: string indicating whether to show the route handler code in the docs. Options are __disabled__, __expanded__ or __collapsed__ (collapsed is the default)
- `theme`: string name of a theme from [bootswatch](http://www.bootswatch.com) to be used as the default theme

@@ -65,0 +68,0 @@ - `groups`: array of [group specs](#group-specs) as described below

@@ -14,6 +14,6 @@ 'use strict';

module.exports = function content (opts) {
return m('main', opts.groups.map(section));
return m('main', opts.groups.map(group => section(group, opts)));
};
function section (group) {
function section (group, opts) {
const name = group.groupName;

@@ -38,3 +38,3 @@ const desc = group.description;

!extd ? '' : m('p', m.trust( markdown( stripIndent(extd) ) )),
group.routes.map((route, index) => routePanel(route, index, group))
group.routes.map((route, index) => routePanel(route, index, group, opts))
])

@@ -44,3 +44,3 @@ ];

function routePanel (route, index, group) {
function routePanel (route, index, group, opts) {
const id = anchor(route);

@@ -53,3 +53,3 @@ const title = get(route, 'meta.friendlyName', route.path);

routeParams(route, index, group),
routeHandler(route, index, group)
opts.routeHandlers === 'disabled' ? null : routeHandler(route, opts)
]),

@@ -70,3 +70,3 @@ routeFooter(route, index, group)

return [
m('p', routeInfo(route.method, route.path, group.prefix)),
routeInfo(route.method, route.path, group.prefix),
!desc ? '' : m('p', desc),

@@ -77,10 +77,6 @@ !extd ? '' : m('p', m.trust( markdown( stripIndent(extd) ) ))

function routeInfo (method, path, prefix = '') {
return m('div.input-group', [
m('span.input-group-btn', m('button.btn.btn-primary', method)),
m('input.form-control', {
type: 'text',
value: `${prefix}${path}`,
style: { paddingLeft: '1em' }
})
function routeInfo (method, path, prefix) {
return m('h4', { style: { marginTop: '0' } }, [
m('span.label.label-primary', { style: { marginRight: '0.5em' } }, method),
(prefix || '') + path
]);

@@ -93,12 +89,15 @@ }

function routeHandler (route) {
function routeHandler (route, opts) {
const handler = stripIndent(` ${route.handler.toString()}`);
const code = m('pre', { style: { border: 0, margin: 0 } }, handler);
const panelOptions = { collapsed: opts.routeHandlers !== 'expanded' };
// Handler is collapsed by default
return collapsablePanel('Handler', { collapsed: true }, code);
return collapsablePanel('Handler', panelOptions, code);
}
function routeFooter (route) {
function routeFooter (route, index, group) {
const transparent = { background: 'transparent' };
const prefix = group.prefix || '';

@@ -110,3 +109,3 @@ return m('div.panel-footer', { style: transparent }, [

route.method.toString().toUpperCase(),
route.path.toString()
prefix + route.path.toString()
].join(' ')),

@@ -113,0 +112,0 @@

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