-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Generate code documentation for the Theia project #401
Conversation
Please add the [WIP] tag to your PR if it's not ready for review |
Also you use use a topic branch.... and not work on master in your fork |
Are you able to run docs with this ? |
packages/core/tdoptions.json
Outdated
@@ -0,0 +1,12 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to have only one tdoptions.json in the root of packages/, kinda like tslint.json? i.e the yarn script would call the doc generator with the options behind ../tdoptions.json from all packages.
We could also have the generated docs folder per packages (i.e package/core/docs/... and package/editor/docs/...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can probably be done. But is it what we want to have docs under each package ? As it is now, it's all bundled under one directory easily tarable. Unless we want to keep a copy in git which resides with the package it documents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can probably be done. But is it what we want to have docs under each package ? As it is now, it's all bundled under one directory easily tarable. Unless we want to keep a copy in git which resides with the package it documents.
Some package.json files were missing from the first pull request. With this version it's possible to generate documentation. I fixed the compilation errors as well. |
Note it's still not possible to run with this PR, you need to add typedoc as a dev dependency |
packages/core/tdoptions.json
Outdated
"experimentalDecorators": true, | ||
"ignoreCompilerErrors": true, | ||
"mode": "file", | ||
"out": "./docs/core", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why repeat the package name ? we're already in it ...
maybe docs/typedoc ? since we may have other docs
[email protected]: | ||
version "2.4.1" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.1.tgz#c3ccb16ddaa0b2314de031e7e6fee89e5ba346bc" | ||
|
||
typescript@^2.4.1: | ||
version "2.4.2" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.2.tgz#f8395f85d459276067c988aa41837a8f82870844" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not clean...it needs to contain only the proper changes
packages/cpp/tdoptions.json
Outdated
"out": "./docs/cpp", | ||
"baseUrl": ".", | ||
"paths": { | ||
"@theia/*": ["node_modules/@theia/*"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this used for ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is actually mandatory on 3 packages: workspace, navigator and monaco. It resolves a typedoc compilation error related to URI.
Argument of type 'URI' is not assignable to parameter of type 'URI'.
Types have separate declarations of a private property 'codeUri'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay, another module loader that has to be tamed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can generate the tdoptions.json all together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should enhance the extension generator to add the docs script as well as the tdoptions.json
packages/core/extension.package.json
Outdated
] | ||
], | ||
"scripts": { | ||
"docs": "typedoc --tsconfig compile.tsconfig.json --options tdoptions.json ." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add this to the extension generator. It is entirely ours and not meant to be used by external extension developers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to move it under the theiaExtensions section of the extension.package.json ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok, you mean the extension-package-generator.ts ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
packages/cpp/tdoptions.json
Outdated
"out": "./docs/cpp", | ||
"baseUrl": ".", | ||
"paths": { | ||
"@theia/*": ["node_modules/@theia/*"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay, another module loader that has to be tamed...
packages/cpp/tdoptions.json
Outdated
"out": "./docs/cpp", | ||
"baseUrl": ".", | ||
"paths": { | ||
"@theia/*": ["node_modules/@theia/*"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can generate the tdoptions.json all together
bfa7fc2
to
1132aca
Compare
"baseUrl": ".", | ||
"paths": { | ||
"@theia/*": ["node_modules/@theia/*"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said before that had no purpose ?
|
||
private getPackageName(): string { | ||
let directoryName = `${process.cwd()}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://nodejs.org/dist/latest-v8.x/docs/api/process.html#process_process_cwd this already returns a string , no reason to use ``
... also if it were not a string you should use .toString()
Also use const rather than let
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this however... see previous comments
|
||
const split = directoryName.split("/"); | ||
return split.reverse()[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use https://nodejs.org/dist/latest-v8.x/docs/api/path.html to get that directory filename using / won't work on windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But actually you don't need this see previous comments
yarn.lock
Outdated
version "1.8.0" | ||
resolved "https://registry.yarnpkg.com/@types/bunyan/-/bunyan-1.8.0.tgz#913bf718a2f4dd1efa063e808cab76609289c986" | ||
version "1.8.2" | ||
resolved "https://registry.yarnpkg.com/@types/bunyan/-/bunyan-1.8.2.tgz#35828136edb33e10d154a570e63771262ba4dc0f" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still wrong see here we update bunyan... we're not adding or removing anything.. so yarn.lock is not ok
"ignoreCompilerErrors": true, | ||
"mode": "file", | ||
"out": "./docs/" + this.getPackageName(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use this.model.pck to get the name
see:
this.model.pck = this.fs.readJSON(
extension.package.json) || {};
In extension-generator.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But actually there's no need for the package name like I said before you are already in the package.... use docs/api
2372b87
to
b2e15a8
Compare
The exclude pattern doesn't work as it is so this tries to doc all node_modules etc.. thus the weird compile errors... and also included a lot of stuff in the package that is not relevant Better to remove the exclude pattern and use the docs on the src/ directory. |
I still get errors like:
I think is may be because of: microsoft/TypeScript#8346 But maybe there is still an issue see the fs paths for the uri typedef:
I'm not sure why we don't have this in the normal compile.tsconfig.json /base et do have it however in tsconfig.json that is used with mocha. We need to use the same thing here too for typedoc. Also you'll notice you get a lof of core stuff in the packages with this so you need to add: "excludeExternals": true, This way it compile fine and you have only what is relevant |
I added a commit that fixes all the issues |
@@ -21,6 +21,7 @@ | |||
"refresh": "node scripts/lerna clean --scope \"@theia/*\" --yes && yarn run bootstrap", | |||
"clean": "node scripts/lerna run clean --scope \"@theia/*\" --parallel", | |||
"build": "node scripts/lerna run build --scope \"@theia/*\" --stream", | |||
"docs": "rimraf docs/api && lerna run docs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that rimraf docs/api is not used anymore it should be that either we output to docs/api or we rimraf docs
I would rather have it that we output to docs/api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it should be "docs": "lerna run docs"
?
Signed-off-by: Guy Perron <[email protected]>
@@ -0,0 +1,30 @@ | |||
{ | |||
"ignoreCompilerErrors": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hexa00 --tsconfig
did not work out?
Signed-off-by: Guy Perron [email protected]