-
Notifications
You must be signed in to change notification settings - Fork 679
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
Support linking to module.d.ts #1117
Conversation
See my question on https://stackoverflow.com/q/58429798/1076463 Creating a link from `firstmodule.d.ts` file to the module `secondmodule.d.ts` is impossible: - The name of the second module that you need to use is `"secondmodule.d"`, e.g. `{@link "secondmodule.d"}` (including the quotes) - However, the name gets split on the `.`, so in the `ProjectReflection#findReflectionByName`, you end up comparing `"secondmodule.d"` with just `d` due to the `const names: string[] = Array.isArray(arg) ? arg : arg.split('.');` line This proposed change strips the `.d` from the name, allowing you to use `{@link "secondmodule"}`. Ideally I would also strip the quotes, but that causes a lot of test failures. My proposed change seems to pass all existing tests, although it affects the json file that gets generated. This sounds like a backwards incompatible change, but no idea how strict the project is on this. I also haven't quite figured out how to add a test for this :-( If this PR is not accepted because you don't want to change the outputted json, can you tell me (or answer on SO) how to create that link.
Fixing linting problems
Hmm, renaming declaration files doesn't seem like a good idea to me, it increases the likelihood of duplicate entries / entries that get confused with each other. What do you think about changing the |
That sounds like it would fix my problem as well |
@Gerrit0 I have changed the PR to use a custom split function. The only thing I am not happy about is the test that I added. To have access to the new utility method in the test, I needed to export it. I have no idea whether there is a better way to fix this. In Java (which am I much more familiar with), I would have used a package private static method and put the test in the same package. This would give the test access to the static method, and avoid that it shows up in the API. If you have any good suggestions on how to fix that, please share them (or simply adjust my PR). |
See my question on https://stackoverflow.com/q/58429798/1076463 Creating a link from `firstmodule.d.ts` file to the module `secondmodule.d.ts` is impossible: - The name of the second module that you need to use is `"secondmodule.d"`, e.g. `{@link "secondmodule.d"}` (including the quotes) - However, the name gets split on the `.`, so in the `ProjectReflection#findReflectionByName`, you end up comparing `"secondmodule.d"` with just `d` due to the `const names: string[] = Array.isArray(arg) ? arg : arg.split('.');` line This proposed change strips the `.d` from the name, allowing you to use `{@link "secondmodule"}`. Ideally I would also strip the quotes, but that causes a lot of test failures. My proposed change seems to pass all existing tests, although it affects the json file that gets generated. This sounds like a backwards incompatible change, but no idea how strict the project is on this. I also haven't quite figured out how to add a test for this :-( If this PR is not accepted because you don't want to change the outputted json, can you tell me (or answer on SO) how to create that link.
Fixing linting problems
… a part is quoted
Hmm, I am relatively new to Github. Tried to rebase my PR to the latest state of master, but that was perhaps not my best idea. Suddenly it looks like I touched a lot of files. |
Rebasing when the same file has been changed with git can easily go wrong. I usually merge when pulling in new changes. Its kind of weird that avoiding the split only works in earlier quoted members ( I think this is an improvement on existing behavior, and everything seems to work locally. Thanks for the contribution! |
Thanks for accepting it. If this was Java (the language I am most familiar with), I would have used:
|
TypeDoc's exported API surface is already badly curated, so I wasn't too worried about adding an extra method to it yet. Ideally, yes, it would be best to not export it on the root level. In the test I'd probably just import it using the full path to the utils file. It's on the list to go through what's exported and what isn't and figure out what should actually be exported. The |
This has been released in 0.15.1 |
See my question on https://stackoverflow.com/q/58429798/1076463
Creating a link from
firstmodule.d.ts
file to the modulesecondmodule.d.ts
is impossible:"secondmodule.d"
, e.g.{@link "secondmodule.d"}
(including the quotes).
, so in theProjectReflection#findReflectionByName
, you end up comparing"secondmodule.d"
with justd
due to theconst names: string[] = Array.isArray(arg) ? arg : arg.split('.');
lineThis proposed change strips the
.d
from the name, allowing you to use{@link "secondmodule"}
.Ideally I would also strip the quotes, but that causes a lot of test failures.
My proposed change seems to pass all existing tests, although it affects the json file that gets generated. This sounds like a backwards incompatible change, but no idea how strict the project is on this.
I also haven't quite figured out how to add a test for this :-(
If this PR is not accepted because you don't want to change the outputted json, can you tell me (or answer on SO) how to create that link.