Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sourceUrl field to all entries #60

Merged
merged 6 commits into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/__tests__/__snapshots__/typescript.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ Object {
},
"kind": "method parameter",
"name": "noise",
"sourceUrl": undefined,
"type": "string",
},
],
"returnType": "Animal",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L9",
"type": "(noise: string) => Animal",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L9",
},
"documentation": Object {
"contents": Array [
Expand Down Expand Up @@ -116,9 +119,11 @@ repository.",
"name": "bark",
"parameters": Array [],
"returnType": "string",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L13",
"type": "() => string",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L13",
},
Object {
"documentation": undefined,
Expand Down Expand Up @@ -176,17 +181,21 @@ repository.",
},
"kind": "method parameter",
"name": "food",
"sourceUrl": undefined,
"type": "string",
},
],
"returnType": "void",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L21",
"type": "(food: string) => void",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L21",
},
],
"name": "Animal",
"properties": Array [],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L9",
},
"Dog": Object {
"constructorType": Object {
Expand Down Expand Up @@ -215,9 +224,11 @@ repository.",
"name": "new Dog",
"parameters": Array [],
"returnType": "Dog",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L33",
"type": "() => Dog",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L33",
},
"documentation": undefined,
"extends": Array [
Expand Down Expand Up @@ -271,9 +282,11 @@ repository.",
"name": "bark",
"parameters": Array [],
"returnType": "string",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L13",
"type": "() => string",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L13",
},
Object {
"documentation": undefined,
Expand Down Expand Up @@ -331,17 +344,21 @@ repository.",
},
"kind": "method parameter",
"name": "food",
"sourceUrl": undefined,
"type": "string",
},
],
"returnType": "void",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L21",
"type": "(food: string) => void",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L21",
},
],
"name": "Dog",
"properties": Array [],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/classes.ts#L33",
},
}
`;
Expand Down Expand Up @@ -393,6 +410,7 @@ Object {
"inheritedFrom": undefined,
"kind": "property",
"name": "disabled",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L17",
"type": "undefined | true | false",
},
Object {
Expand Down Expand Up @@ -420,6 +438,7 @@ Object {
"inheritedFrom": undefined,
"kind": "property",
"name": "iconName",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L20",
"type": "IconName",
},
Object {
Expand Down Expand Up @@ -447,6 +466,7 @@ Object {
"inheritedFrom": undefined,
"kind": "property",
"name": "intent",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L23",
"type": "Intent",
},
Object {
Expand Down Expand Up @@ -474,6 +494,7 @@ Object {
"inheritedFrom": undefined,
"kind": "property",
"name": "onClick",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L26",
"type": "(event: MouseEvent) => void",
},
Object {
Expand Down Expand Up @@ -501,9 +522,11 @@ Object {
"inheritedFrom": undefined,
"kind": "property",
"name": "text",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L29",
"type": "string",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L15",
},
"IButtonProps": Object {
"documentation": undefined,
Expand Down Expand Up @@ -554,6 +577,7 @@ This is equivalent to setting \`className=\\"pt-active\\"\`.",
"inheritedFrom": undefined,
"kind": "property",
"name": "active",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L38",
"type": "undefined | true | false",
},
Object {
Expand Down Expand Up @@ -581,6 +605,7 @@ This is equivalent to setting \`className=\\"pt-active\\"\`.",
"inheritedFrom": "IActionProps.disabled",
"kind": "property",
"name": "disabled",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L17",
"type": "undefined | true | false",
},
Object {
Expand Down Expand Up @@ -608,6 +633,7 @@ This is equivalent to setting \`className=\\"pt-active\\"\`.",
"inheritedFrom": undefined,
"kind": "property",
"name": "elementRef",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L41",
"type": "undefined | (ref: HTMLElement) => any",
},
Object {
Expand Down Expand Up @@ -635,6 +661,7 @@ This is equivalent to setting \`className=\\"pt-active\\"\`.",
"inheritedFrom": "IActionProps.iconName",
"kind": "property",
"name": "iconName",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L20",
"type": "IconName",
},
Object {
Expand Down Expand Up @@ -662,6 +689,7 @@ This is equivalent to setting \`className=\\"pt-active\\"\`.",
"inheritedFrom": "IActionProps.intent",
"kind": "property",
"name": "intent",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L23",
"type": "Intent",
},
Object {
Expand Down Expand Up @@ -691,6 +719,7 @@ The width of the button is not affected by the value of this prop.",
"inheritedFrom": undefined,
"kind": "property",
"name": "loading",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L55",
"type": "undefined | true | false",
},
Object {
Expand Down Expand Up @@ -718,6 +747,7 @@ The width of the button is not affected by the value of this prop.",
"inheritedFrom": "IActionProps.onClick",
"kind": "property",
"name": "onClick",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L26",
"type": "(event: MouseEvent) => void",
},
Object {
Expand Down Expand Up @@ -745,6 +775,7 @@ The width of the button is not affected by the value of this prop.",
"inheritedFrom": undefined,
"kind": "property",
"name": "rightIconName",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L47",
"type": "IconName",
},
Object {
Expand Down Expand Up @@ -772,6 +803,7 @@ The width of the button is not affected by the value of this prop.",
"inheritedFrom": "IActionProps.text",
"kind": "property",
"name": "text",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L29",
"type": "string",
},
Object {
Expand Down Expand Up @@ -801,9 +833,11 @@ Note that this prop has no effect on \`AnchorButton\`; it only affects \`Button\
"inheritedFrom": undefined,
"kind": "property",
"name": "type",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L62",
"type": "undefined | string",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L32",
},
"ICompiler": Object {
"documentation": Object {
Expand Down Expand Up @@ -881,6 +915,7 @@ callback to extract key from each item.",
},
"kind": "method parameter",
"name": "array",
"sourceUrl": undefined,
"type": "T[]",
},
Object {
Expand All @@ -900,13 +935,16 @@ callback to extract key from each item.",
},
"kind": "method parameter",
"name": "getKey",
"sourceUrl": undefined,
"type": "(item: T) => string",
},
],
"returnType": "{ [key: string]: T }",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L73",
"type": "(array: T[], getKey: (item: T) => string) => { [key: string]: T }",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L73",
},
Object {
"documentation": undefined,
Expand Down Expand Up @@ -968,6 +1006,7 @@ is.",
},
"kind": "method parameter",
"name": "blockContent",
"sourceUrl": undefined,
"type": "string",
},
Object {
Expand All @@ -987,13 +1026,16 @@ is.",
},
"kind": "method parameter",
"name": "reservedTagWords",
"sourceUrl": undefined,
"type": "string[]",
},
],
"returnType": "object",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L84",
"type": "(blockContent: string, reservedTagWords?: string[]) => object",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L84",
},
Object {
"documentation": undefined,
Expand Down Expand Up @@ -1044,17 +1086,21 @@ is.",
},
"kind": "method parameter",
"name": "markdown",
"sourceUrl": undefined,
"type": "string",
},
],
"returnType": "string",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L89",
"type": "(markdown: string) => string",
},
],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L89",
},
],
"name": "ICompiler",
"properties": Array [],
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L68",
},
"IconName": Object {
"documentation": undefined,
Expand All @@ -1072,6 +1118,7 @@ is.",
},
"kind": "type alias",
"name": "IconName",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L13",
"type": "\\"add\\" | \\"remove\\" | \\"plus\\" | \\"minus\\"",
},
"Intent": Object {
Expand Down Expand Up @@ -1107,6 +1154,7 @@ is.",
},
"kind": "enum member",
"name": "Danger",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L11",
},
Object {
"defaultValue": undefined,
Expand All @@ -1125,6 +1173,7 @@ is.",
},
"kind": "enum member",
"name": "Primary",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L8",
},
Object {
"defaultValue": undefined,
Expand All @@ -1143,6 +1192,7 @@ is.",
},
"kind": "enum member",
"name": "Success",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L9",
},
Object {
"defaultValue": undefined,
Expand All @@ -1161,9 +1211,11 @@ is.",
},
"kind": "enum member",
"name": "Warning",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L10",
},
],
"name": "Intent",
"sourceUrl": "https://github.com/palantir/documentalist/blob/develop/src/__tests__/__fixtures__/interfaces.ts#L7",
},
}
`;
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function expectSnapshot(
/** a function to transform the DM data, to avoid snapshotting _everything_. defaults to identity function. */
transform: (data: ITypescriptPluginData["typescript"]) => any = arg => arg,
) {
const dm = Documentalist.create().use(".ts", new TypescriptPlugin(options));
const dm = Documentalist.create().use(".ts", new TypescriptPlugin({ ...options, gitBranch: "develop" }));
const { typescript } = await dm.documentGlobs(`src/__tests__/__fixtures__/${name}.ts`);
expect(transform(typescript)).toMatchSnapshot();
}
16 changes: 13 additions & 3 deletions src/client/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,28 @@ export interface ITsFlags {
}

/** Base type for all typescript documentation members. */
export interface ITsDocBase {
export interface ITsDocBase<K extends Kind = Kind> {
/** Type brand indicating kind of member; type guards will reveal further information about it. */
kind: Kind;
kind: K;

/** Compiled documentation: `contents` field contains an array of markdown strings or `@tag value` objects. */
documentation?: IBlock;

/** Original file name in which this member originated. */
/** Original file name in which this member originated, relative to current working directory. */
fileName?: string;

flags?: ITsFlags;

/** Name of this member in code, also used as its identifiers in the data store. */
name: string;

/**
* Absolute URL pointing to source file in repository, including line number.
* If `gitBranch` option is provided to the `TypescriptPlugin`, the URL will reference that branch.
* Otherwise, it will reference the current commit hash.
* @see ITypescriptPluginOptions.gitBranch
*/
sourceUrl?: string;
}

/**
Expand Down Expand Up @@ -113,6 +121,8 @@ export interface ITsMethodParameter extends ITsDocBase, ITsDefaultValue {
kind: Kind.MethodParameter;
/** Fully qualified type string describing this parameter. */
type: string;
/** Parameters do not have their own URL; see the containing signature. */
sourceUrl: undefined;
}

/** Documentation for a property of an object, which may have a default value. */
Expand Down
Loading