TypeStrong / typedoc

Documentation generator for TypeScript projects.
https://typedoc.org
Apache License 2.0
7.67k stars 693 forks source link

TypeDoc uses the wrong readme file #1066

Closed trusktr closed 3 years ago

trusktr commented 5 years ago

Expected Behavior

My project is called infamous. The package.json file contains:

{
    "name": "infamous",
    "version": "21.0.6",
    "description": "A CSS3D/WebGL UI library.",

I expect the name of the project to show up as "infamous" in the generated HTML site.

Actual Behavior

However, the name appears as "lowclass",

Screen Shot 2019-07-04 at 6 49 56 PM

where "lowclass" is a dependency of my project.

Steps to reproduce the bug

Clone github.com/infamous/infamous, run typedoc.

Environment

trusktr commented 5 years ago

It marks all the actual content from my project as "external":

Screen Shot 2019-07-04 at 7 01 29 PM
Gerrit0 commented 5 years ago

Well that's certainly unexpected. It looks like it also picked up the readme from your dependency. I think the cause of the bug is here: https://github.com/TypeStrong/typedoc/blob/master/src/lib/converter/plugins/PackagePlugin.ts#L85

TypeDoc shouldn't assume the first SourceFile it documents is in the project that is being documented. I'm not entirely sure how this should be fixed right now... maybe we should be resolving the readme.md & package.json files relative to the current working directory, but that will cause problems if you try to run TypeDoc when not in the root directory of a project.

lf94 commented 4 years ago

I've now also been hit with this. My solution was to move the 1st dependency to another line, but I find this super confusing. This is not really a solution if you're using tslint which will tell you your imports are not alphabetized.

At the very least, developers should be able to specify a package.json, README.md and directory to start walking the project (usually src/).

lf94 commented 4 years ago

Two solutions I came up with for those coming from a search engine:

Gerrit0 commented 3 years ago

As far as I can tell, this should be fixed in 0.20. In that version, instead of looking through source files, we find the package + readme starting from the root directory of all TS files in the project.