How to use the documentation.util function in documentation

To help you get started, we’ve selected a few documentation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github infor-design / enterprise / docs / templates / documentationjs / theme-ids-website / index.js View on Github external
/* eslint-disable */
var fs = require('fs'),
  path = require('path'),
  File = require('vinyl'),
  vfs = require('vinyl-fs'),
  _ = require('lodash'),
  concat = require('concat-stream'),
  GithubSlugger = require('github-slugger'),
  createFormatters = require('documentation').util.createFormatters,
  LinkerStack = require('documentation').util.LinkerStack,
  hljs = require('highlight.js');

function isFunction(section) {
  return (
    section.kind === 'function' ||
    (section.kind === 'typedef' &&
      section.type.type === 'NameExpression' &&
      section.type.name === 'Function')
  );
}

module.exports = function(
  comments,
  config
) {
  var linkerStack = new LinkerStack(config).namespaceResolver(
github infor-design / enterprise / docs / documentationjs / theme-soho / index.js View on Github external
/* eslint-disable import/no-extraneous-dependencies, prefer-destructuring,
no-mixed-operators, guard-for-in, no-buffer-constructor, no-restricted-syntax */

const fs = require('fs');
const path = require('path');
const write = require('vinyl-write');
const Vinyl = require('vinyl');
const _ = require('lodash');
const GithubSlugger = require('github-slugger');
const createFormatters = require('documentation').util.createFormatters;
const LinkerStack = require('documentation').util.LinkerStack;
const hljs = require('highlight.js');

function isFunction(section) {
  return section.kind === 'function' || section.kind === 'typedef' &&
    section.type.type === 'NameExpression' && section.type.name === 'Function';
}

module.exports = function (comments, config) {
  const linkerStack = new LinkerStack(config).namespaceResolver(comments, (namespace) => {
    const slugger = new GithubSlugger();
    return `#${slugger.slug(namespace)}`;
  });
  const formatters = createFormatters(linkerStack.link);

  // Add an Index
github logux / logux.io / scripts / steps / build-api.js View on Github external
'Array',
  'function',
  'boolean',
  'string',
  'object',
  'number',
  'any'
])
const KINDS = [
  ['Functions', i => i.kind === 'function'],
  ['Callbacks', i => i.kind === 'typedef' && isCallback(i)],
  ['Types', i => i.kind === 'typedef' && !isCallback(i)],
  ['Constants', i => i.kind === 'constant']
]

let formatters = documentation.util.createFormatters()

function toSlug (type) {
  let slug = type
  if (!CAPITALIZED.test(slug)) slug = 'globals-' + slug
  return slugify(slug).toLowerCase()
}

function toSourceUrl ({ file, loc }) {
  return file.replace(
    /^.*\/logux-([^/]+)\/(.*)$/,
    'https://github.com/logux/$1/blob/master/$2'
  ) + `#L${ loc.start.line }L${ loc.end.line }`
}

function byName (a, b) {
  if (CAPITALIZED.test(a.name) && !CAPITALIZED.test(b.name)) {
github styled-components / polished / docs-theme / index.js View on Github external
const fs = require('fs')
const path = require('path')
const File = require('vinyl')
const vfs = require('vinyl-fs')
const _ = require('lodash')
const concat = require('concat-stream')
const GithubSlugger = require('github-slugger')
const createFormatters = require('documentation').util.createFormatters
const LinkerStack = require('documentation').util.LinkerStack
const hljs = require('highlight.js')

function isFunction(section) {
  return (
    section.kind === 'function' ||
    (section.kind === 'typedef' &&
      section.type.type === 'NameExpression' &&
      section.type.name === 'Function')
  )
}

module.exports = function (comments, config, callback) {
  const linkerStack = new LinkerStack(config).namespaceResolver(
    comments,
    function (namespace) {
      const slugger = new GithubSlugger()
github styled-components / polished / docs-theme / index.js View on Github external
const fs = require('fs')
const path = require('path')
const File = require('vinyl')
const vfs = require('vinyl-fs')
const _ = require('lodash')
const concat = require('concat-stream')
const GithubSlugger = require('github-slugger')
const createFormatters = require('documentation').util.createFormatters
const LinkerStack = require('documentation').util.LinkerStack
const hljs = require('highlight.js')

function isFunction(section) {
  return (
    section.kind === 'function' ||
    (section.kind === 'typedef' &&
      section.type.type === 'NameExpression' &&
      section.type.name === 'Function')
  )
}

module.exports = function (comments, config, callback) {
  const linkerStack = new LinkerStack(config).namespaceResolver(
    comments,
    function (namespace) {
github Pixpipe / pixpipejs / docgen / themes / pixpipe_theme / index.js View on Github external
'use strict';

var fs = require('fs'),
    path = require('path'),
    File = require('vinyl'),
    vfs = require('vinyl-fs'),
    _ = require('lodash'),
    concat = require('concat-stream'),
    GithubSlugger = require('github-slugger'),
    createFormatters = require('documentation').util.createFormatters,
    LinkerStack = require('documentation').util.LinkerStack,
    hljs = require('highlight.js');

function isFunction(section) {
  return section.kind === 'function' || section.kind === 'typedef' && section.type.type === 'NameExpression' && section.type.name === 'Function';
}

module.exports = function (comments, config) {
  var linkerStack = new LinkerStack(config).namespaceResolver(comments, function (namespace) {
    var slugger = new GithubSlugger();
    return '#' + slugger.slug(namespace);
  });

  var formatters = createFormatters(linkerStack.link);

  hljs.configure(config.hljs || {});
github mhkeller / indian-ocean / docs / default_theme / index.js View on Github external
'use strict';

var fs = require('fs'),
    path = require('path'),
    File = require('vinyl'),
    vfs = require('vinyl-fs'),
    _ = require('lodash'),
    concat = require('concat-stream'),
    GithubSlugger = require('github-slugger'),
    createFormatters = require('documentation').util.createFormatters,
    LinkerStack = require('documentation').util.LinkerStack,
    hljs = require('highlight.js');

function isFunction(section) {
  return section.kind === 'function' || section.kind === 'typedef' && section.type.type === 'NameExpression' && section.type.name === 'Function';
}
module.exports = function (comments, config) {
  var linkerStack = new LinkerStack(config).namespaceResolver(comments, function (namespace) {
    var slugger = new GithubSlugger();
    return '#' + slugger.slug(namespace, true);
  });

  var formatters = createFormatters(linkerStack.link);

  hljs.configure(config.hljs || {});

  var sharedImports = {
github Pixpipe / pixpipejs / docgen / themes / pixpipe_theme / index.js View on Github external
'use strict';

var fs = require('fs'),
    path = require('path'),
    File = require('vinyl'),
    vfs = require('vinyl-fs'),
    _ = require('lodash'),
    concat = require('concat-stream'),
    GithubSlugger = require('github-slugger'),
    createFormatters = require('documentation').util.createFormatters,
    LinkerStack = require('documentation').util.LinkerStack,
    hljs = require('highlight.js');

function isFunction(section) {
  return section.kind === 'function' || section.kind === 'typedef' && section.type.type === 'NameExpression' && section.type.name === 'Function';
}

module.exports = function (comments, config) {
  var linkerStack = new LinkerStack(config).namespaceResolver(comments, function (namespace) {
    var slugger = new GithubSlugger();
    return '#' + slugger.slug(namespace);
  });

  var formatters = createFormatters(linkerStack.link);

  hljs.configure(config.hljs || {});
github mhkeller / indian-ocean / docs / default_theme / index.js View on Github external
'use strict';

var fs = require('fs'),
    path = require('path'),
    File = require('vinyl'),
    vfs = require('vinyl-fs'),
    _ = require('lodash'),
    concat = require('concat-stream'),
    GithubSlugger = require('github-slugger'),
    createFormatters = require('documentation').util.createFormatters,
    LinkerStack = require('documentation').util.LinkerStack,
    hljs = require('highlight.js');

function isFunction(section) {
  return section.kind === 'function' || section.kind === 'typedef' && section.type.type === 'NameExpression' && section.type.name === 'Function';
}
module.exports = function (comments, config) {
  var linkerStack = new LinkerStack(config).namespaceResolver(comments, function (namespace) {
    var slugger = new GithubSlugger();
    return '#' + slugger.slug(namespace, true);
  });

  var formatters = createFormatters(linkerStack.link);

  hljs.configure(config.hljs || {});
github dignifiedquire / clean-documentation-theme / src / utils.js View on Github external
'use strict'

const GithubSlugger = require('github-slugger')
const hljs = require('highlight.js')
const util = require('documentation').util
const createFormatters = util.createFormatters
const LinkerStack = util.LinkerStack
const _ = require('lodash')

module.exports = class Utils {
  constructor (options, comments) {
    this.linkerStack = new LinkerStack(options)
      .namespaceResolver(comments, (namespace) => {
        const slugger = new GithubSlugger()
        return '#' + slugger.slug(namespace)
      })

    this.options = options
    this.comments = comments
    this.formatters = createFormatters(this.linkerStack.link)
    this.options.hljs = this.options.hljs || {}