Skip to content

Config option to exclude not explicitly documented symbols (#995) #996

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 24 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3f50767
Added Mixin sample
canonic-epicure Mar 11, 2019
b0f108e
use different names for different parts of mixin declaration
canonic-epicure Mar 12, 2019
43518d2
added declaration of class with mixin
canonic-epicure Mar 12, 2019
22dee9a
better test data
canonic-epicure Mar 13, 2019
478899d
Take into account the case, when base type of the class/interface is …
canonic-epicure Mar 13, 2019
0d8b552
only merge the declarations of the same kind
canonic-epicure Mar 13, 2019
97ef64b
better mixin example
canonic-epicure Mar 13, 2019
12d231a
lint
canonic-epicure Mar 18, 2019
0bb9005
mixin sample
canonic-epicure Mar 18, 2019
f0013cf
do not merge reflections for type and value
canonic-epicure Mar 18, 2019
dafce20
lint
canonic-epicure Mar 18, 2019
26a960b
bumped TypeScript dependency
canonic-epicure Mar 19, 2019
912ba26
lint pass
canonic-epicure Mar 19, 2019
2431ba0
fix lint errors on Node6
canonic-epicure Mar 20, 2019
bfdff3c
Update src/lib/converter/factories/declaration.ts
aciccarello Mar 21, 2019
d4f3ba8
added a test fixture for the mixins
canonic-epicure Mar 21, 2019
b2365f1
Merge remote-tracking branch 'origin/master'
canonic-epicure Mar 21, 2019
8f7e075
`excludeNotDocumented` config option for converter
canonic-epicure Mar 25, 2019
c4d9b1c
Merge remote-tracking branch 'primary/master'
canonic-epicure Mar 25, 2019
c81a00e
always include enum members, even if those are not documented
canonic-epicure Mar 25, 2019
89330ce
Merge remote-tracking branch 'primary/master'
canonic-epicure Feb 24, 2020
714f987
merged latest master
canonic-epicure Feb 24, 2020
d2f01b7
fixes for the --mode modules
canonic-epicure Feb 25, 2020
593d34f
fix: Broken tests
Gerrit0 Feb 28, 2020
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
4 changes: 4 additions & 0 deletions scripts/rebuild_specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const conversions = [
() => app.options.setValue('categorizeByGroup', false),
() => app.options.setValue('categorizeByGroup', true)
],
['specs.nodoc',
() => app.options.setValue('excludeNotDocumented', true),
() => app.options.setValue('excludeNotDocumented', false)
]
];

/**
Expand Down
3 changes: 3 additions & 0 deletions src/lib/converter/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export class Converter extends ChildableComponent<Application, ConverterComponen
@BindOption('excludeNotExported')
excludeNotExported!: boolean;

@BindOption('excludeNotDocumented')
excludeNotDocumented!: boolean;

@BindOption('excludePrivate')
excludePrivate!: boolean;

Expand Down
9 changes: 8 additions & 1 deletion src/lib/converter/factories/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as ts from 'typescript';
import { ContainerReflection, DeclarationReflection, ReflectionFlag, ReflectionKind } from '../../models/index';
import { Context } from '../context';
import { Converter } from '../converter';
import { getRawComment } from './comment.js';
import { createReferenceType } from './reference';

/**
Expand Down Expand Up @@ -69,10 +70,12 @@ export function createDeclaration(context: Context, node: ts.Declaration, kind:

const modifiers = ts.getCombinedModifierFlags(node);

let hasComment: boolean = Boolean(getRawComment(node));
// Test whether the node is exported
let isExported: boolean;
if (kind === ReflectionKind.ExternalModule || kind === ReflectionKind.Global) {
isExported = true;
hasComment = true;
} else if (container.kind === ReflectionKind.Global) {
// In file mode, everything is exported.
isExported = true;
Expand All @@ -98,7 +101,11 @@ export function createDeclaration(context: Context, node: ts.Declaration, kind:
isExported = container.flags.isExported;
}

if (!isExported && context.converter.excludeNotExported) {
if (
(!isExported && context.converter.excludeNotExported)
||
(context.converter.excludeNotDocumented && kind !== ReflectionKind.EnumMember && !hasComment)
) {
return;
}

Expand Down
5 changes: 5 additions & 0 deletions src/lib/utils/options/sources/typedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export function addTypeDocOptions(options: Options) {
help: 'Prevent symbols that are not exported from being documented.',
type: ParameterType.Boolean
});
options.addDeclaration({
name: 'excludeNotDocumented',
help: 'Prevent symbols that are not explicitly documented from appearing in the results.',
type: ParameterType.Boolean
});
options.addDeclaration({
name: 'excludePrivate',
help: 'Ignores private variables and methods',
Expand Down
36 changes: 36 additions & 0 deletions src/test/converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,39 @@ describe('Serializer', () => {
equal(json, typed);
});
});

// describe('Converter with excludeNotDocumented=true', function() {
// const base = Path.join(__dirname, 'converter');
// const fixtureDir = Path.join(base, 'exclude-not-documented');
// let app: Application;
//
// before('constructs', function() {
// app = new Application({
// mode: 'Modules',
// logger: 'none',
// target: 'ES5',
// module: 'CommonJS',
// experimentalDecorators: true,
// excludeNotDocumented: true,
// jsx: 'react'
// });
// });
//
// let result: ProjectReflection | undefined;
//
// describe('Exclude not documented symbols', () => {
// it('converts fixtures', function() {
// resetReflectionID();
// result = app.convert(app.expandInputFiles([fixtureDir]));
// Assert(result instanceof ProjectReflection, 'No reflection returned');
// });
//
// it('matches specs', function() {
// const specs = JSON.parse(FS.readFileSync(Path.join(fixtureDir, 'specs-without-undocumented.json')).toString());
// let data = JSON.stringify(result!.toObject(), null, ' ');
// data = data.split(normalizePath(base)).join('%BASE%');
//
// compareReflections(JSON.parse(data), specs);
// });
// });
// });
Loading