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

Clobber generic/default options with more specific options #587

Conversation

thecjharries
Copy link
Contributor

@thecjharries thecjharries commented Sep 4, 2017

This fixes an issue where typedoc clobbers the CLI path with the found options from tsconfig.json or typedoc.js. It took me a bit to figure everything out:

[0, -100, -100].sort((a, b) => b - a)
// [0, -100, -100]
new Array(10).fill(0).map((value, index) => index).sort((a, b) => b - a)
// [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

I've been trying to figure this out for too many hours, so I don't have a demo prepped. I can make one later. This folder structure

/project
    <optional tsconfig.json>
    some-file.ts
    src/
        some-other-file.ts
    docs/

used with this command

typedoc --out docs/ src/some-other-file.ts

will always generate documentation for both some-other-file AND some-file.

- Move ArgumentsReader priority below TSConfigReader
- Replace file array instead of pushing as TSConfigReader also clobbers
Fat-fingered the 9 instead of the 0; tests pass either way
@thecjharries
Copy link
Contributor Author

This should address #527. I didn't think to check the issues until after submitting the PR. I'll search for more after I get some sleep.

@thecjharries
Copy link
Contributor Author

The branch name isn't as descriptive now. After thinking about this a bit morning this morning, I realized the duplicated priority in TypedocReader and TSConfigReader could, in rare cases, lead to unexpected results.

By changing the priority, the load order is now TSConfigReader > TypedocReader > ArgumentsReader, which allows the most generic to be overwritten by the most specific (e.g. inputFiles start at **/* with a generic tsconfig.json, are replaced by src inside a typedoc.js, and are overwritten by a specified CLI argument).

Applications (and their descendants CliApplications) are bootstrapped via two option reads, allowing generics to be built in order of most to least specific in the first read, then replaced by the desired objects in the second read. Discrete priorities means the order is finally well-defined and the Options will load in a predictable manner.

@thecjharries thecjharries changed the title Clobber inputfiles with arguments Clobber generic/default options with more specific options Sep 4, 2017
thecjharries added a commit to wizardsoftheweb/opensimplex-noise that referenced this pull request Sep 4, 2017
After fighting config for a very long, I went upstream and discovered the cause of my issues was this:
TypeStrong/typedoc#587
@blakeembrey
Copy link
Member

Thanks @thecjharries!

@blakeembrey blakeembrey merged commit 482821c into TypeStrong:master Sep 22, 2017
@beevik
Copy link

beevik commented Oct 10, 2017

This commit seems to have broken the processing of the "files" array in tsconfig.json.

See #617

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants