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

Generate code documentation for the Theia project #401

Merged
merged 1 commit into from
Aug 25, 2017

Conversation

lmcgupe
Copy link
Contributor

@lmcgupe lmcgupe commented Aug 18, 2017

Signed-off-by: Guy Perron [email protected]

@hexa00
Copy link

hexa00 commented Aug 18, 2017

Please add the [WIP] tag to your PR if it's not ready for review

@lmcgupe lmcgupe changed the title Generate code documentation for the Theia project [WIP] Generate code documentation for the Theia project Aug 18, 2017
@hexa00
Copy link

hexa00 commented Aug 18, 2017

Also you use use a topic branch.... and not work on master in your fork

@hexa00
Copy link

hexa00 commented Aug 18, 2017

Are you able to run docs with this ?

@@ -0,0 +1,12 @@
{
Copy link
Contributor

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/...)

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@lmcgupe
Copy link
Contributor Author

lmcgupe commented Aug 18, 2017

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.

@hexa00
Copy link

hexa00 commented Aug 21, 2017

Note it's still not possible to run with this PR, you need to add typedoc as a dev dependency

"experimentalDecorators": true,
"ignoreCompilerErrors": true,
"mode": "file",
"out": "./docs/core",
Copy link

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"
Copy link

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

"out": "./docs/cpp",
"baseUrl": ".",
"paths": {
"@theia/*": ["node_modules/@theia/*"]
Copy link

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 ?

Copy link
Contributor Author

@lmcgupe lmcgupe Aug 22, 2017

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'

Copy link
Contributor

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...

Copy link
Contributor

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

Copy link
Contributor

@svenefftinge svenefftinge left a 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

]
],
"scripts": {
"docs": "typedoc --tsconfig compile.tsconfig.json --options tdoptions.json ."
Copy link
Contributor

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

Copy link
Contributor Author

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 ?

Copy link
Contributor Author

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 ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

"out": "./docs/cpp",
"baseUrl": ".",
"paths": {
"@theia/*": ["node_modules/@theia/*"]
Copy link
Contributor

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...

"out": "./docs/cpp",
"baseUrl": ".",
"paths": {
"@theia/*": ["node_modules/@theia/*"]
Copy link
Contributor

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

@lmcgupe lmcgupe force-pushed the master branch 3 times, most recently from bfa7fc2 to 1132aca Compare August 24, 2017 15:43
"baseUrl": ".",
"paths": {
"@theia/*": ["node_modules/@theia/*"]
Copy link

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()}`;
Copy link

@hexa00 hexa00 Aug 24, 2017

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

Copy link

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];
Copy link

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

Copy link

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"
Copy link

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(),
Copy link

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

Copy link

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

@lmcgupe lmcgupe force-pushed the master branch 3 times, most recently from 2372b87 to b2e15a8 Compare August 24, 2017 19:54
@hexa00
Copy link

hexa00 commented Aug 25, 2017

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.
(see more detailed comments inline)

@hexa00
Copy link

hexa00 commented Aug 25, 2017

I still get errors like:

Using TypeScript 2.4.1 from /home/eantotr/sync/work/theia/node_modules/typedoc/node_modules/typescript/lib
Error: /home/eantotr/sync/work/theia/packages/workspace/src/browser/workspace-frontend-contribution.ts(67)
 Argument of type 'URI' is not assignable to parameter of type 'URI'.
  Types have separate declarations of a private property 'codeUri'.
Error: /home/eantotr/sync/work/theia/packages/workspace/src/browser/workspace-frontend-contribution.ts(69)
 Argument of type 'URI' is not assignable to parameter of type 'URI'.
Error: /home/eantotr/sync/work/theia/packages/workspace/src/browser/workspace-service.ts(32)
 Argument of type 'URI' is not assignable to parameter of type 'URI'.
  Types have separate declarations of a private property 'codeUri'.
Rendering [========================================] 100%

I think is may be because of: microsoft/TypeScript#8346
It should be fixed by: microsoft/TypeScript#8486

But maybe there is still an issue see the fs paths for the uri typedef:

./node_modules/@theia/filesystem/node_modules/@theia/preferences-api/node_modules/@theia/core/lib/common/uri.d.ts
./node_modules/@theia/filesystem/node_modules/@theia/core/lib/common/uri.d.ts
./node_modules/@theia/core/lib/common/uri.d.ts

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

@hexa00
Copy link

hexa00 commented Aug 25, 2017

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",
Copy link

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

Copy link
Member

@akosyakov akosyakov Aug 25, 2017

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"?

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Signed-off-by: Guy Perron <[email protected]>
@hexa00 hexa00 changed the title [WIP] Generate code documentation for the Theia project Generate code documentation for the Theia project Aug 25, 2017
@lmcgupe lmcgupe merged commit 86e0942 into eclipse-theia:master Aug 25, 2017
@@ -0,0 +1,30 @@
{
"ignoreCompilerErrors": true,
Copy link
Member

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?

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.

None yet

5 participants