Skip to content

Add no revision option #474

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

Merged
merged 4 commits into from
Apr 12, 2017
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -62,7 +62,6 @@ in order to change the behaviour of TypeDoc.
Prevent externally resolved TypeScript files from being documented.
* `--excludePrivate`<br>
Prevent private members from being included in the generated documentation.


#### TypeScript compiler
* `--module <commonjs, amd, system or umd>`<br>
Expand All @@ -86,6 +85,8 @@ in order to change the behaviour of TypeDoc.
Set the site name for Google Analytics. Defaults to `auto`
* `--entryPoint <fully.qualified.name>`<br>
Specifies the fully qualified name of the root symbol. Defaults to global namespace.
* `--gitRevision <revision|branch>`<br>
Use specified revision or branch instead of the last revision for linking to GitHub source files.

#### Content
* `--includes <path/to/includes>`<br>
Expand Down
28 changes: 20 additions & 8 deletions src/lib/converter/plugins/GitHubPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good time to remove manual shelljs typing if possible. Or we could do this in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely leave it for a different PR 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have that already in a different branch. Will create a PR once this is merged.

declare module 'shelljs' {
Expand All @@ -30,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.
Expand All @@ -52,8 +54,9 @@ class Repository {
*
* @param path The root path of the repository.
*/
constructor(path: string) {
constructor(path: string, gitRevision: string) {
this.path = path;
this.branch = gitRevision || 'master';
ShellJS.pushd(path);

let out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git ls-remote --get-url', {silent: true});
Expand Down Expand Up @@ -82,9 +85,11 @@ class Repository {
});
}

out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git rev-parse --short HEAD', {silent: true});
if (out.code === 0) {
this.branch = out.stdout.replace('\n', '');
if (!gitRevision) {
out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git rev-parse --short HEAD', {silent: true});
if (out.code === 0) {
this.branch = out.stdout.replace('\n', '');
}
}

ShellJS.popd();
Expand Down Expand Up @@ -130,15 +135,15 @@ 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, gitRevision: string): Repository {
ShellJS.pushd(path);
const out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git rev-parse --show-toplevel', {silent: true});
ShellJS.popd();

if (out.code !== 0) {
return null;
}
return new Repository(BasePath.normalize(out.stdout.replace('\n', '')));
return new Repository(BasePath.normalize(out.stdout.replace('\n', '')), gitRevision);
}
}

Expand All @@ -158,6 +163,13 @@ export class GitHubPlugin extends ConverterComponent {
*/
private ignoredPaths: string[] = [];

@Option({
name: 'gitRevision',
help: 'Use specified revision instead of the last revision for linking to GitHub source files.',
type: ParameterType.String
})
gitRevision: string;

/**
* Create a new GitHubHandler instance.
*
Expand Down Expand Up @@ -196,7 +208,7 @@ export class GitHubPlugin extends ConverterComponent {
}

// Try to create a new repository
const repository = Repository.tryCreateRepository(dirName);
const repository = Repository.tryCreateRepository(dirName, this.gitRevision);
if (repository) {
this.repositories[repository.path] = repository;
return repository;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions src/test/renderer/specs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ <h4 id="theming">Theming</h4>
Set the site name for Google Analytics. Defaults to <code>auto</code></li>
<li><code>--entryPoint &lt;fully.qualified.name&gt;</code><br>
Specifies the fully qualified name of the root symbol. Defaults to global namespace.</li>
<li><code>--gitRevision &lt;revision|branch&gt;</code><br>
Use specified revision or branch instead of the last revision for linking to GitHub source files.</li>
</ul>
<h4 id="content">Content</h4>
<ul>
Expand Down