Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

documentalist

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

documentalist - npm Package Compare versions

Comparing version 0.0.8 to 0.1.1

dist/client/compiler.d.ts

11

cli.js
#!/usr/bin/env node
// @ts-check

@@ -15,6 +16,7 @@ // Example Usage

const glob = require("glob");
const { Documentalist, KssPlugin, MarkdownPlugin, TypedocPlugin, TypescriptPlugin } = require("./dist/");
const { Documentalist, KssPlugin, MarkdownPlugin, TypescriptPlugin } = require("./dist/");
const argv = yargs
.alias("v", "version")
// @ts-ignore
.version(require("./package.json").version)

@@ -45,8 +47,3 @@ .usage("$0 [options] <files>")

if (argv.ts) {
docs = docs.use(/\.tsx?$/, new TypescriptPlugin({
excludePaths: ["__tests__"],
}));
docs = docs.use(/\.tsx?$/, new TypedocPlugin({
excludePaths: ["__tests__"],
}));
docs = docs.use(/\.tsx?$/, new TypescriptPlugin({ exclude: "**/__tests__/**" }));
}

@@ -53,0 +50,0 @@ if (argv.css) {

@@ -7,97 +7,17 @@ /**

*/
/**
* This module exports all __client__ interfaces: Documentalist concepts that are meant to be used at runtime
* alongside a compiled documentation data file.
*
* The `Documentalist` class and its plugins are only available at compile-time, but their interfaces are useful
* when rendering the data, so they are exposed separately in this module.
*
* A few utility functions are also provided, including several type guards for `@tags`.
*/
export * from "./compiler";
export * from "./kss";
export * from "./markdown";
export * from "./typedoc";
export * from "./plugin";
export * from "./tags";
export * from "./typescript";
export * from "./utils";
/**
* The basic components of a navigable resource: a "route" at which it can be accessed and
* its depth in the layout hierarchy. Heading tags and hierarchy nodes both extend this interface.
*/
export interface INavigable {
/** Fully-qualified route of the heading, which can be used as anchor `href`. */
route: string;
/** Level of heading, from 1-6. Dictates which `<h#>` tag to render. */
level: number;
}
/** Represents a single `@tag <value>` line from a file. */
export interface ITag {
/** Tag name. */
tag: string;
/** Tag value, exactly as written in source. */
value: string;
}
/**
* Represents a single `@#+ <value>` heading tag from a file. Note that all `@#+` tags
* (`@#` through `@######`) are emitted as `tag: "heading"` so only one renderer is necessary to
* capture all six levels.
*
* Heading tags include additional information over regular tags: fully-qualified `route` of the
* heading (which can be used as anchor `href`), and `level` to determine which `<h#>` tag to use.
*/
export interface IHeadingTag extends ITag, INavigable {
tag: "heading";
}
/** An entry in `contents` array: either an HTML string or an `@tag`. */
export declare type StringOrTag = string | ITag;
/**
* Metadata is parsed from YAML front matter in files and can contain arbitrary data.
* A few keys are understood by Documentalist and, if defined in front matter,
* will override default behavior.
*
* ```md
* ---
* reference: overview
* title: "Welcome to the Jungle"
* ---
* actual contents of file...
* ```
*/
export interface IMetadata {
/**
* Unique ID for addressing this page.
* @default filename without extension
*/
reference?: string;
/**
* Human-friendly title of this page, for display in the UI.
* @default value of first `@#` tag
*/
title?: string;
[key: string]: any;
}
/**
* The output of `renderBlock` which parses a long form documentation block into
* metadata, rendered markdown, and tags.
*/
export interface IBlock {
/** Parsed nodes of source file. An array of markdown-rendered HTML strings or `@tag` objects. */
contents: StringOrTag[];
/** Raw unmodified contents of source file (excluding the metadata). */
contentsRaw: string;
/** Arbitrary YAML metadata parsed from front matter of source file, if any, or `{}`. */
metadata: IMetadata;
}
/**
* A single Documentalist page, parsed from a single source file.
*/
export interface IPageData extends IBlock {
/** Unique identifier for addressing this page. */
reference: string;
/** Fully qualified route to this page: slash-separated references of all parent pages. */
route: string;
/** Human-friendly title of this page. */
title: string;
}
/** An `@#+` tag belongs to a specific page. */
export interface IHeadingNode extends INavigable {
/** Display title of page heading. */
title: string;
}
/** A page has ordered children composed of `@#+` and `@page` tags. */
export interface IPageNode extends IHeadingNode {
/** Ordered list of pages and headings that appear on this page. */
children: Array<IPageNode | IHeadingNode>;
/** Unique reference of this page, used for retrieval from store. */
reference: string;
}

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
function __export(m) {

@@ -13,2 +13,3 @@ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./typescript"));
__export(require("./utils"));

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -7,3 +7,4 @@ /**

*/
import { IPageData, IPageNode } from "./index";
import { IBlock } from "./compiler";
import { INavigable } from "./tags";
export interface IMarkdownPluginData {

@@ -21,1 +22,24 @@ /**

}
/**
* A single Documentalist page, parsed from a single source file.
*/
export interface IPageData extends IBlock {
/** Unique identifier for addressing this page. */
reference: string;
/** Fully qualified route to this page: slash-separated references of all parent pages. */
route: string;
/** Human-friendly title of this page. */
title: string;
}
/** An `@#+` tag belongs to a specific page. */
export interface IHeadingNode extends INavigable {
/** Display title of page heading. */
title: string;
}
/** A page has ordered children composed of `@#+` and `@page` tags. */
export interface IPageNode extends IHeadingNode {
/** Ordered list of pages and headings that appear on this page. */
children: Array<IPageNode | IHeadingNode>;
/** Unique reference of this page, used for retrieval from store. */
reference: string;
}

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -7,22 +7,87 @@ /**

*/
import { IJsDocTags } from "ts-quick-docs";
import { IBlock } from "./index";
export interface ITsDocEntry {
documentation: IBlock;
import { IBlock } from "./compiler";
/** Enumeration describing the various kinds of member supported by this plugin. */
export declare enum Kind {
Class = "class",
Interface = "interface",
Method = "method",
Parameter = "parameter",
Property = "property",
Signature = "signature",
}
/** Compiler flags about this member. */
export interface ITsFlags {
isDeprecated?: boolean | string;
isExported?: boolean;
isExternal?: boolean;
isOptional?: boolean;
isPrivate?: boolean;
isProtected?: boolean;
isPublic?: boolean;
isRest?: boolean;
isStatic?: boolean;
}
/** Base type for all typescript documentation members. */
export interface ITsDocBase {
/** Type brand indicating kind of member; type guards will reveal further information about it. */
kind: Kind;
/** Compiled documentation: `contents` field contains an array of markdown strings or `@tag value` objects. */
documentation?: IBlock;
/** Original file name in which this member originated. */
fileName?: string;
flags?: ITsFlags;
/** Name of this member in code, also used as its identifiers in the data store. */
name: string;
tags?: IJsDocTags;
}
/** Documentation for a method. See `signatures` array for actual callable signatures and rendered docs. */
export interface ITsMethod extends ITsDocBase {
kind: Kind.Method;
/** A method has at least one signature, which describes the parameters and return type and contains documentation. */
signatures: ITsMethodSignature[];
}
/** Documentation for a single method signature, including parameters, return type, and full type string. */
export interface ITsMethodSignature extends ITsDocBase {
kind: Kind.Signature;
parameters: ITsMethodParameter[];
returnType: string;
type: string;
}
export interface ITsPropertyEntry extends ITsDocEntry {
optional?: boolean;
/** Documentation for a single parameter to a method signature. */
export interface ITsMethodParameter extends ITsDocBase {
kind: Kind.Parameter;
/** The default value of this property, from an initializer or an `@default` tag. */
defaultValue?: string;
type: string;
}
export interface ITsInterfaceEntry extends ITsDocEntry {
extends?: string[];
properties: ITsPropertyEntry[];
/** Documentation for a property of an object, which may have a default value. */
export interface ITsProperty extends ITsDocBase {
kind: Kind.Property;
/** The default value of this property, from an initializer or an `@default` tag. */
defaultValue?: string;
/** Type descriptor of this property. */
type: string;
}
export interface ITsObjectDefinition {
properties: ITsProperty[];
methods: ITsMethod[];
}
/** Documentation for an `interface` definition. */
export interface ITsInterface extends ITsDocBase, ITsObjectDefinition {
kind: Kind.Interface;
}
/** Documentation for a `class` definition. */
export interface ITsClass extends ITsDocBase, ITsObjectDefinition {
kind: Kind.Class;
}
/**
* The `TypescriptPlugin` exports a `typescript` key that contains a map of member name to
* `class` or `interface` definition.
*
* Only classes and interfaces are provided at this root level, but each member contains full
* information about its children, such as methods (and signatures and parameters) and properties.
*/
export interface ITypescriptPluginData {
ts: {
[name: string]: ITsInterfaceEntry;
typescript: {
[name: string]: ITsClass | ITsInterface;
};
}

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,12 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/** Enumeration describing the various kinds of member supported by this plugin. */
var Kind;
(function (Kind) {
Kind["Class"] = "class";
Kind["Interface"] = "interface";
Kind["Method"] = "method";
Kind["Parameter"] = "parameter";
Kind["Property"] = "property";
Kind["Signature"] = "signature";
})(Kind = exports.Kind || (exports.Kind = {}));

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,4 +20,3 @@ /** Slugify a string: "Really Cool Heading!" => "really-cool-heading-" */

function isTag(node, tagName) {
return node != null && node.tag !== undefined
&& (tagName === undefined || node.tag === tagName);
return (node != null && node.tag !== undefined && (tagName === undefined || node.tag === tagName));
}

@@ -24,0 +23,0 @@ exports.isTag = isTag;

/// <reference types="marked" />
import { IBlock } from "./client";
import { ICompiler } from "./plugins";
import * as marked from "marked";
import { IBlock, ICompiler } from "./client";
export interface ICompilerOptions {
/** Options for markdown rendering. See https://github.com/chjj/marked#options-1. */
markdown?: MarkedOptions;
markdown?: marked.MarkedOptions;
/**

@@ -8,0 +8,0 @@ * Reserved @tags that should be preserved in the contents string.

"use strict";
/**
* Copyright 2017-present Palantir Technologies, Inc. All rights reserved.
* Licensed under the BSD-3 License as modified (the “License”); you may obtain
* a copy of the license in the LICENSE and PATENTS files in the root of this
* repository.
*/
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,3 +25,3 @@ const yaml = require("js-yaml");

this.renderBlock = (blockContent, reservedTagWords = this.options.reservedTags) => {
const { contentsRaw, metadata } = this.extractMetadata(blockContent);
const { contentsRaw, metadata } = this.extractMetadata(blockContent.trim());
const contents = this.renderContents(contentsRaw, reservedTagWords);

@@ -40,4 +46,4 @@ return { contents, contentsRaw, metadata };

return splitContents
.map((node) => typeof node === "string" ? this.renderMarkdown(node) : node)
.filter((node) => node !== "");
.map(node => (typeof node === "string" ? this.renderMarkdown(node) : node))
.filter(node => node !== "");
}

@@ -79,3 +85,4 @@ /**

// NOTE: not enough information to populate `route` field yet
arr.push({ tag: "heading", value, level: tag.length });
const heading = { tag: "heading", value, level: tag.length, route: "" };
arr.push(heading);
}

@@ -82,0 +89,0 @@ else {

@@ -0,3 +1,3 @@

import { IFile, IPlugin } from "./client";
import { ICompilerOptions } from "./compiler";
import { IFile, IPlugin } from "./plugins";
export interface IApi<T> {

@@ -4,0 +4,0 @@ /**

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -49,5 +49,7 @@ return new (P || (P = Promise))(function (resolve, reject) {

const compiler = new compiler_1.Compiler(this.options);
// need an empty object of correct type that we can merge into
// tslint:disable-next-line:no-object-literal-type-assertion
const documentation = {};
for (const { pattern, plugin } of this.plugins) {
const pluginFiles = files.filter((f) => pattern.test(f.path));
const pluginFiles = files.filter(f => pattern.test(f.path));
const pluginDocumentation = yield plugin.compile(pluginFiles, compiler);

@@ -64,5 +66,5 @@ this.mergeInto(documentation, pluginDocumentation);

return filesGlobs
.map((filesGlob) => glob.sync(filesGlob))
.map(filesGlob => glob.sync(filesGlob))
.reduce((a, b) => a.concat(b))
.map((fileName) => {
.map(fileName => {
const absolutePath = path.resolve(fileName);

@@ -69,0 +71,0 @@ return {

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
function __export(m) {

@@ -10,0 +10,0 @@ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -56,3 +56,3 @@ const client_1 = require("./client");

const pageNode = initPageNode(page, depth);
page.contents.forEach((node) => {
page.contents.forEach(node => {
// we only care about @page and @##+ tag nodes

@@ -76,4 +76,4 @@ if (client_1.isTag(node, "page")) {

function initHeadingNode(title, level) {
// NOTE: `route` will be added in MarkdownPlugin.
return { title, level };
// NOTE: `route` will be populated in MarkdownPlugin.
return { title, level, route: "" };
}

@@ -9,4 +9,2 @@ /**

export * from "./markdown";
export * from "./typedoc";
export * from "./typescript";
export * from "./plugin";
export * from "./typescript/index";

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
function __export(m) {

@@ -15,3 +15,2 @@ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];

__export(require("./markdown"));
__export(require("./typedoc"));
__export(require("./typescript"));
__export(require("./typescript/index"));

@@ -8,7 +8,6 @@ /**

import * as kss from "kss";
import { IKssExample, IKssPluginData } from "../client";
import { ICompiler, IFile, IPlugin } from "./plugin";
import { ICompiler, IFile, IKssExample, IKssPluginData, IPlugin } from "../client";
export declare class KssPlugin implements IPlugin<IKssPluginData> {
private options;
constructor(options: kss.IOptions);
constructor(options?: kss.IOptions);
compile(cssFiles: IFile[], dm: ICompiler): {

@@ -15,0 +14,0 @@ css: {

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -13,3 +13,3 @@ const kss = require("kss");

class KssPlugin {
constructor(options) {
constructor(options = {}) {
this.options = options;

@@ -19,8 +19,8 @@ }

const styleguide = this.parseFiles(cssFiles);
const sections = styleguide.sections().map((s) => convertSection(s, dm));
const css = dm.objectify(sections, (s) => s.reference);
const sections = styleguide.sections().map(s => convertSection(s, dm));
const css = dm.objectify(sections, s => s.reference);
return { css };
}
parseFiles(files) {
const input = files.map((file) => ({
const input = files.map(file => ({
base: path.dirname(file.path),

@@ -40,3 +40,3 @@ contents: file.read(),

markupHtml: dm.renderMarkdown(`\`\`\`html\n${section.markup() || ""}\n\`\`\``),
modifiers: section.modifiers().map((mod) => convertModifier(mod, dm)),
modifiers: section.modifiers().map(mod => convertModifier(mod, dm)),
reference: section.reference(),

@@ -43,0 +43,0 @@ };

@@ -1,3 +0,2 @@

import { IMarkdownPluginData, IPageData, IPageNode } from "../client";
import { ICompiler, IFile, IPlugin } from "./plugin";
import { ICompiler, IFile, IMarkdownPluginData, IPageData, IPageNode, IPlugin } from "../client";
export interface IMarkdownPluginOptions {

@@ -4,0 +3,0 @@ /**

@@ -0,1 +1,2 @@

"use strict";
/**

@@ -7,3 +8,2 @@ * Copyright 2017-present Palantir Technologies, Inc. All rights reserved.

*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -54,6 +54,6 @@ const path = require("path");

// compute route for page and heading NODES (from nav tree)
const path = parent === undefined ? [] : [parent.route];
const baseRoute = parent === undefined ? [] : [parent.route];
const route = client_1.isPageNode(node)
? path.concat(node.reference).join("/")
: path.concat(client_1.slugify(node.title)).join(".");
? baseRoute.concat(node.reference).join("/")
: baseRoute.concat(client_1.slugify(node.title)).join(".");
node.route = route;

@@ -64,15 +64,10 @@ if (client_1.isPageNode(node)) {

page.route = route;
page.contents.forEach((content) => {
page.contents.forEach(content => {
// inject `route` field into heading TAGS (from page contents)
if (client_1.isHeadingTag(content)) {
// h1 tags do not get nested as they are used as page title
if (content.level > 1) {
content.route = [route, client_1.slugify(content.value)].join(".");
}
else {
content.route = route;
}
content.route = content.level > 1 ? [route, client_1.slugify(content.value)].join(".") : route;
}
});
node.children.forEach((child) => this.recurseRoute(pageMap, child, node));
node.children.forEach(child => this.recurseRoute(pageMap, child, node));
}

@@ -79,0 +74,0 @@ }

{
"name": "documentalist",
"version": "0.0.8",
"version": "0.1.1",
"description": "documentation for the rest of us",

@@ -10,38 +10,38 @@ "main": "dist/index.js",

},
"scripts": {
"clean": "rm -rf dist",
"docs": "pug -O docs.json ./theme/index.pug --pretty -o ./docs",
"docs:json": "./cli.js './{src,typings}/**/*' > docs.json",
"lint": "tslint --project .",
"lint.fix": "yarn lint --fix",
"test": "jest --config jest.config.json",
"tsc": "tsc --project .",
"watch": "yarn tsc --watch"
},
"dependencies": {
"glob": "^7.1.1",
"js-yaml": "^3.7.0",
"kss": "3.0.0-beta.15",
"marked": "^0.3.6",
"ts-quick-docs": "^0.5.3",
"typedoc": "^0.7.1",
"yargs": "^6.6.0"
"js-yaml": "^3.10.0",
"kss": "^3.0.0-beta.18",
"marked": "^0.3.7",
"typedoc": "^0.9.0",
"yargs": "^10.0.3"
},
"devDependencies": {
"@blueprintjs/tslint-config": "^1.0.1",
"@types/glob": "^5.0.30",
"@types/jest": "^19.2.2",
"@types/js-yaml": "^3.5.28",
"@types/marked": "^0.0.28",
"@types/node": "^6.0.52",
"@types/react": "^15.0.14",
"@types/yargs": "^6.6.0",
"@types/jest": "^21.1.8",
"@types/js-yaml": "^3.10.1",
"@types/marked": "^0.3.0",
"@types/node": "^8.5.1",
"@types/react": "^16.0.31",
"@types/yargs": "^10.0.0",
"circle-github-bot": "^0.4.0",
"jest": "^19.0.2",
"npm-run-all": "^4.0.2",
"jest": "^22.0.3",
"npm-run-all": "^4.1.2",
"pug-cli": "^1.0.0-alpha6",
"ts-jest": "^19.0.2",
"ts-node": "^2.1.0",
"tslint": "^4.5.1",
"typescript": "^2.2.1"
"ts-jest": "^22.0.0",
"ts-node": "^4.0.2",
"tslint": "^5.8.0",
"typescript": "^2.6.2"
},
"scripts": {
"clean": "rm -rf dist",
"docs": "pug -O docs.json ./theme/index.pug --pretty -o ./docs",
"docs:json": "./cli.js './{src,typings}/**/*' > docs.json",
"lint": "tslint --project .",
"lint.fix": "tslint --fix --project . ",
"test": "jest --config jest.config.json",
"tsc": "tsc --project . && echo 'OK'",
"watch": "tsc --project . --watch"
},
"repository": {

@@ -48,0 +48,0 @@ "type": "git",

@@ -23,10 +23,11 @@ # Documentalist

```js
const { Documentalist, MarkdownPlugin } = require("documentalist");
const { Documentalist, MarkdownPlugin, TypescriptPlugin } = require("documentalist");
const { writeFileSync } = require("fs");
const docs = new Documentalist()
new Documentalist()
.use(".md", new MarkdownPlugin())
.documentGlobs("src/**/*");
writeFileSync("docs.json", JSON.stringify(docs, null, 2));
.use(/\.tsx?$/, new TypescriptPlugin({ excludeNames: [/I.+State$/] }))
.documentGlobs("src/**/*")
.then(docs => JSON.stringify(docs, null, 2))
.then(json => writeFileSync("docs.json", json))
```

@@ -33,0 +34,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc