From 18d1ea97bdf57f8995f540535f555fb4c62aa363 Mon Sep 17 00:00:00 2001 From: Silas Rech Date: Mon, 10 Apr 2017 16:02:34 +0200 Subject: [PATCH 1/4] Add option to not use the last revision for linking to GitHub source files --- README.md | 5 ++-- src/lib/converter/plugins/GitHubPlugin.ts | 31 ++++++++++++++++++----- src/test/renderer/specs/index.html | 2 ++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 06524f12a..2d4a1f3f5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > Documentation generator for TypeScript projects. -[![Build Status](https://travis-ci.org/TypeStrong/typedoc.svg?branch=master)](https://travis-ci.org/TypeStrong/typedoc) +[![Build Status](https://travis-ci.org/TypeStrong/typedoc.svg?branch=master)](https://travis-ci.org/TypeStrong/typedoc) [![NPM Version](https://badge.fury.io/js/typedoc.svg)](http://badge.fury.io/js/typedoc) [![Chat on Gitter](https://badges.gitter.im/TypeStrong/typedoc.svg)](https://gitter.im/TypeStrong/typedoc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -62,7 +62,6 @@ in order to change the behaviour of TypeDoc. Prevent externally resolved TypeScript files from being documented. * `--excludePrivate`
Prevent private members from being included in the generated documentation. - #### TypeScript compiler * `--module `
@@ -86,6 +85,8 @@ in order to change the behaviour of TypeDoc. Set the site name for Google Analytics. Defaults to `auto` * `--entryPoint `
Specifies the fully qualified name of the root symbol. Defaults to global namespace. +* `--noRevision`
+ Do not use the last revision for linking to GitHub source files. Will use the `master` branch instead. #### Content * `--includes `
diff --git a/src/lib/converter/plugins/GitHubPlugin.ts b/src/lib/converter/plugins/GitHubPlugin.ts index fea3565a3..6a578f95b 100644 --- a/src/lib/converter/plugins/GitHubPlugin.ts +++ b/src/lib/converter/plugins/GitHubPlugin.ts @@ -6,6 +6,8 @@ import {Component, ConverterComponent} from '../components'; import {BasePath} from '../utils/base-path'; import {Converter} from '../converter'; import {Context} from '../context'; +import {Option} from '../../utils/component'; +import {ParameterType} from '../../utils/options/declaration'; // This should be removed when @typings/shelljs typings are updated to the shelljs version being used declare module 'shelljs' { @@ -47,13 +49,19 @@ class Repository { */ gitHubProject: string; + /** + * Whether to use revisions or not. + */ + noRevision: boolean; + /** * Create a new Repository instance. * * @param path The root path of the repository. */ - constructor(path: string) { + constructor(path: string, noRevision: boolean) { this.path = path; + this.noRevision = noRevision; ShellJS.pushd(path); let out = ShellJS.exec('git ls-remote --get-url', {silent: true}); @@ -82,9 +90,11 @@ class Repository { }); } - out = ShellJS.exec('git rev-parse --short HEAD', {silent: true}); - if (out.code === 0) { - this.branch = out.stdout.replace('\n', ''); + if (!this.noRevision) { + out = ShellJS.exec('git rev-parse --short HEAD', {silent: true}); + if (out.code === 0) { + this.branch = out.stdout.replace('\n', ''); + } } ShellJS.popd(); @@ -130,7 +140,7 @@ class Repository { * @param path The potential repository root. * @returns A new instance of [[Repository]] or NULL. */ - static tryCreateRepository(path: string): Repository { + static tryCreateRepository(path: string, noRevision: boolean): Repository { ShellJS.pushd(path); const out = ShellJS.exec('git rev-parse --show-toplevel', {silent: true}); ShellJS.popd(); @@ -138,7 +148,7 @@ class Repository { if (out.code !== 0) { return null; } - return new Repository(BasePath.normalize(out.stdout.replace('\n', ''))); + return new Repository(BasePath.normalize(out.stdout.replace('\n', '')), noRevision); } } @@ -158,6 +168,13 @@ export class GitHubPlugin extends ConverterComponent { */ private ignoredPaths: string[] = []; + @Option({ + name: 'noRevision', + help: 'Do not use the last revision for linking to GitHub source files. Will use the master branch instead.', + type: ParameterType.Boolean + }) + noRevision: boolean; + /** * Create a new GitHubHandler instance. * @@ -196,7 +213,7 @@ export class GitHubPlugin extends ConverterComponent { } // Try to create a new repository - const repository = Repository.tryCreateRepository(dirName); + const repository = Repository.tryCreateRepository(dirName, this.noRevision); if (repository) { this.repositories[repository.path] = repository; return repository; diff --git a/src/test/renderer/specs/index.html b/src/test/renderer/specs/index.html index 004937c12..1928fcf58 100644 --- a/src/test/renderer/specs/index.html +++ b/src/test/renderer/specs/index.html @@ -138,6 +138,8 @@

Theming

Set the site name for Google Analytics. Defaults to auto
  • --entryPoint <fully.qualified.name>
    Specifies the fully qualified name of the root symbol. Defaults to global namespace.
  • +
  • --noRevision
    + Do not use the last revision for linking to GitHub source files. Will use the master branch instead.
  • Content

      From e72352ee4c22d31d484d10d828897a3118fecd40 Mon Sep 17 00:00:00 2001 From: Silas Rech Date: Tue, 11 Apr 2017 22:31:57 +0200 Subject: [PATCH 2/4] Allow specifying the revision to use --- README.md | 4 ++-- src/lib/converter/plugins/GitHubPlugin.ts | 24 ++++++++++++----------- src/lib/converter/types/index.ts | 2 +- src/test/renderer/specs/index.html | 4 ++-- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 2d4a1f3f5..23977b375 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,8 @@ in order to change the behaviour of TypeDoc. Set the site name for Google Analytics. Defaults to `auto` * `--entryPoint `
      Specifies the fully qualified name of the root symbol. Defaults to global namespace. -* `--noRevision`
      - Do not use the last revision for linking to GitHub source files. Will use the `master` branch instead. +* `--revision `
      + Use specified revision instead of the last revision for linking to GitHub source files. #### Content * `--includes `
      diff --git a/src/lib/converter/plugins/GitHubPlugin.ts b/src/lib/converter/plugins/GitHubPlugin.ts index 6a578f95b..5b985fe91 100644 --- a/src/lib/converter/plugins/GitHubPlugin.ts +++ b/src/lib/converter/plugins/GitHubPlugin.ts @@ -52,16 +52,16 @@ class Repository { /** * Whether to use revisions or not. */ - noRevision: boolean; + revision: string; /** * Create a new Repository instance. * * @param path The root path of the repository. */ - constructor(path: string, noRevision: boolean) { + constructor(path: string, revision: string) { this.path = path; - this.noRevision = noRevision; + this.revision = revision; ShellJS.pushd(path); let out = ShellJS.exec('git ls-remote --get-url', {silent: true}); @@ -90,11 +90,13 @@ class Repository { }); } - if (!this.noRevision) { + if (!this.revision) { out = ShellJS.exec('git rev-parse --short HEAD', {silent: true}); if (out.code === 0) { this.branch = out.stdout.replace('\n', ''); } + } else if (this.revision) { + this.branch = this.revision; } ShellJS.popd(); @@ -140,7 +142,7 @@ class Repository { * @param path The potential repository root. * @returns A new instance of [[Repository]] or NULL. */ - static tryCreateRepository(path: string, noRevision: boolean): Repository { + static tryCreateRepository(path: string, revision: string): Repository { ShellJS.pushd(path); const out = ShellJS.exec('git rev-parse --show-toplevel', {silent: true}); ShellJS.popd(); @@ -148,7 +150,7 @@ class Repository { if (out.code !== 0) { return null; } - return new Repository(BasePath.normalize(out.stdout.replace('\n', '')), noRevision); + return new Repository(BasePath.normalize(out.stdout.replace('\n', '')), revision); } } @@ -169,11 +171,11 @@ export class GitHubPlugin extends ConverterComponent { private ignoredPaths: string[] = []; @Option({ - name: 'noRevision', - help: 'Do not use the last revision for linking to GitHub source files. Will use the master branch instead.', - type: ParameterType.Boolean + name: 'revision', + help: 'Use specified revision instead of the last revision for linking to GitHub source files.', + type: ParameterType.String }) - noRevision: boolean; + revision: string; /** * Create a new GitHubHandler instance. @@ -213,7 +215,7 @@ export class GitHubPlugin extends ConverterComponent { } // Try to create a new repository - const repository = Repository.tryCreateRepository(dirName, this.noRevision); + const repository = Repository.tryCreateRepository(dirName, this.revision); if (repository) { this.repositories[repository.path] = repository; return repository; diff --git a/src/lib/converter/types/index.ts b/src/lib/converter/types/index.ts index 97965cf62..b9ba3a520 100644 --- a/src/lib/converter/types/index.ts +++ b/src/lib/converter/types/index.ts @@ -3,7 +3,7 @@ export {ArrayConverter} from './array'; export {BindingArrayConverter} from './binding-array'; export {BindingObjectConverter} from './binding-object'; export {EnumConverter} from './enum'; -export {IntrinsicConverter} from './intrinsic' +export {IntrinsicConverter} from './intrinsic'; export {StringLiteralConverter} from './string-literal'; export {ReferenceConverter} from './reference'; export {ThisConverter} from './this'; diff --git a/src/test/renderer/specs/index.html b/src/test/renderer/specs/index.html index 1928fcf58..f441a40a8 100644 --- a/src/test/renderer/specs/index.html +++ b/src/test/renderer/specs/index.html @@ -138,8 +138,8 @@

      Theming

      Set the site name for Google Analytics. Defaults to auto
    • --entryPoint <fully.qualified.name>
      Specifies the fully qualified name of the root symbol. Defaults to global namespace.
    • -
    • --noRevision
      - Do not use the last revision for linking to GitHub source files. Will use the master branch instead.
    • +
    • --revision <revision>
      + Use specified revision instead of the last revision for linking to GitHub source files.

    Content

      From 4865fce97835542e150d47aada2b23e53148588f Mon Sep 17 00:00:00 2001 From: Silas Rech Date: Thu, 13 Apr 2017 01:13:42 +0200 Subject: [PATCH 3/4] Apply suggestions by @blakeembrey --- src/lib/converter/plugins/GitHubPlugin.ts | 25 ++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/lib/converter/plugins/GitHubPlugin.ts b/src/lib/converter/plugins/GitHubPlugin.ts index 5b985fe91..e9dabecc7 100644 --- a/src/lib/converter/plugins/GitHubPlugin.ts +++ b/src/lib/converter/plugins/GitHubPlugin.ts @@ -32,7 +32,7 @@ class Repository { /** * The name of the branch this repository is on right now. */ - branch = 'master'; + branch: string; /** * A list of all files tracked by the repository. @@ -49,19 +49,14 @@ class Repository { */ gitHubProject: string; - /** - * Whether to use revisions or not. - */ - revision: string; - /** * Create a new Repository instance. * * @param path The root path of the repository. */ - constructor(path: string, revision: string) { + constructor(path: string, gitRevision: string) { this.path = path; - this.revision = revision; + this.branch = gitRevision || 'master'; ShellJS.pushd(path); let out = ShellJS.exec('git ls-remote --get-url', {silent: true}); @@ -90,13 +85,11 @@ class Repository { }); } - if (!this.revision) { + if (!gitRevision) { out = ShellJS.exec('git rev-parse --short HEAD', {silent: true}); if (out.code === 0) { this.branch = out.stdout.replace('\n', ''); } - } else if (this.revision) { - this.branch = this.revision; } ShellJS.popd(); @@ -142,7 +135,7 @@ class Repository { * @param path The potential repository root. * @returns A new instance of [[Repository]] or NULL. */ - static tryCreateRepository(path: string, revision: string): Repository { + static tryCreateRepository(path: string, gitRevision: string): Repository { ShellJS.pushd(path); const out = ShellJS.exec('git rev-parse --show-toplevel', {silent: true}); ShellJS.popd(); @@ -150,7 +143,7 @@ class Repository { if (out.code !== 0) { return null; } - return new Repository(BasePath.normalize(out.stdout.replace('\n', '')), revision); + return new Repository(BasePath.normalize(out.stdout.replace('\n', '')), gitRevision); } } @@ -171,11 +164,11 @@ export class GitHubPlugin extends ConverterComponent { private ignoredPaths: string[] = []; @Option({ - name: 'revision', + name: 'gitRevision', help: 'Use specified revision instead of the last revision for linking to GitHub source files.', type: ParameterType.String }) - revision: string; + gitRevision: string; /** * Create a new GitHubHandler instance. @@ -215,7 +208,7 @@ export class GitHubPlugin extends ConverterComponent { } // Try to create a new repository - const repository = Repository.tryCreateRepository(dirName, this.revision); + const repository = Repository.tryCreateRepository(dirName, this.gitRevision); if (repository) { this.repositories[repository.path] = repository; return repository; From 0755987524135f1b0bec52d0771f2483a12c611b Mon Sep 17 00:00:00 2001 From: Silas Rech Date: Thu, 13 Apr 2017 01:16:46 +0200 Subject: [PATCH 4/4] Apply changes in previous commits to documentation as well --- README.md | 4 ++-- src/test/renderer/specs/index.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 23977b375..8517088a1 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,8 @@ in order to change the behaviour of TypeDoc. Set the site name for Google Analytics. Defaults to `auto` * `--entryPoint `
      Specifies the fully qualified name of the root symbol. Defaults to global namespace. -* `--revision `
      - Use specified revision instead of the last revision for linking to GitHub source files. +* `--gitRevision `
      + Use specified revision or branch instead of the last revision for linking to GitHub source files. #### Content * `--includes `
      diff --git a/src/test/renderer/specs/index.html b/src/test/renderer/specs/index.html index f441a40a8..fda968da7 100644 --- a/src/test/renderer/specs/index.html +++ b/src/test/renderer/specs/index.html @@ -138,8 +138,8 @@

      Theming

      Set the site name for Google Analytics. Defaults to auto
    • --entryPoint <fully.qualified.name>
      Specifies the fully qualified name of the root symbol. Defaults to global namespace.
    • -
    • --revision <revision>
      - Use specified revision instead of the last revision for linking to GitHub source files.
    • +
    • --gitRevision <revision|branch>
      + Use specified revision or branch instead of the last revision for linking to GitHub source files.

    Content