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

correctly write doclets at es6 class constructors #74

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

HackbrettXXX
Copy link
Contributor

A pull request to correctly write doc comments at es6 class constructors like described here.

Copy link
Owner

@englercj englercj left a comment

Choose a reason for hiding this comment

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

Couple stylistic nit-picks.

Can you also add a test for this please?

src/Emitter.ts Outdated
import { assertNever } from './assert_never';
import {Dictionary} from './Dictionary';
import {warn} from './logger';
import {assertNever} from './assert_never';
Copy link
Owner

Choose a reason for hiding this comment

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

Fix these whitespace changes please.

src/Emitter.ts Outdated
} from './create_helpers';
import {createFunctionParams} from "./type_resolve_helpers";
Copy link
Owner

Choose a reason for hiding this comment

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

nit: spaces between braces

@@ -279,6 +273,29 @@ export function createClassMember(doclet: IMemberDoclet): ts.PropertyDeclaration
));
}

function getAccessModifiers(doclet: IMemberDoclet | IClassDoclet) {
Copy link
Owner

Choose a reason for hiding this comment

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

nit: Newline before braces, don't use K&R style braces.

@HackbrettXXX
Copy link
Contributor Author

HackbrettXXX commented Apr 24, 2019

I just realized that this approach only works if the class is exported using export default. Otherwise, the constructor and class documentations are merged into a single doclet by jsdoc. This doclet has a description (for constructor doc) and classdesc property, as well as params. access defined at the constructor is lost, unfortunately.

By the way, how do you debug the tests? Are you using Webstorm? Somehow the debugger cannot attach to the sources of the template.

@englercj
Copy link
Owner

By the way, how do you debug the tests? Are you using Webstorm? Somehow the debugger cannot attach to the sources of the template.

I don't use Webstorm I use Code and haven't had an issue debugging it before. Generally I setup a minimal test file and launch a parse process from Code against that one file to debug the specific issue I'm hitting.

alxroyer added a commit to alxroyer/tsd-jsdoc that referenced this pull request Sep 6, 2019
@alxroyer
Copy link
Contributor

alxroyer commented Sep 6, 2019

@englercj, @HackbrettXXX, I think I managed to fix the things around this topic.

Please see the PR#98.
I started with cherry-picking @HackbrettXXX's commits, and eventually brought fixes in commit 82e01e4.

Key changes:

  • publish.ts: avoid removing doclets with an 'undocumented' attribute abusively set to true by jsdoc
  • Emitter.ts: fix the predicates for isConstructor()

englercj pushed a commit that referenced this pull request May 2, 2020
* Very first 'export default' generation.
Still buggy: module declaration is generated twice.

* Removal of the IExportDefaultDoclet hack.

* Code moved from _createTreeNodes() to _buildTree() for 'export default' doclets.
=> fixed: generation of 'export default' at the end of the module (and not at the beginning)
=> fixed: duplicate module declaration

* 'module.exports =' pattern management.
module2 test addition.

* module3 test addition.

* Removal of K&R style braces.
`debug()` controled by a specific `debug` option.

* Addition of debug traces.

* opts.generationStrategy option addition.
'documented' => by default
'exported' => not fully implemented, just prevents non documented doclets to be removed for the moment

* correctly write doclets at es6 class constructors
cherry-pick & merge from @HackbrettXXX's commit 312578e

* add a test case for constructors (fails currently)

* Constructor generation with documentation.
From [PR#74](#74) with fix.

* Emitter._buildTree() strengthening with full jsdoc doclets.

* First 'exported' generation strategy implementation. Still needs to be tested.

* Test additions for testing the 'exported' generation strategy.
Lots of them are not enabled yet and need to be fixed.

* (Re)named exports.

* Warning addition while waiting for [tsd-jsdoc#104](#104 resolution.

* 'export <named type>' pattern support.
Fix for 'module.exports = {name: }' pattern.

* Named exports with reference to a type of the same name.

* 'export default <named type>' pattern support (works like a lambda class would actually).

* 'export default <lambda class>' pattern support.

* 'export default <lambda function>' and 'export default <named function>' patterns support.

* 'module.exports=<lambda type>' and 'module.exports=<named type>' patterns support.

* 'module.exports.name=<lambda type>' and 'module.exports.name=<named type>' patterns support.

* 'exports.name=<lambda type>' and 'exports.name=<named type>' patterns support.

* 'module.exports={name=<lambda type>} and 'module.exports={name=<named type>}' patterns support.
Workaround needed for classes as long as issue [jsdoc#1699](jsdoc/jsdoc#1699) is not fixed.

* cyclic dependencies with 'exported' generation strategy.
Addition of 'export default {name: ...}' tests (not supported yet).

* Test class_all.js working with 'exported' generation strategy.

* Test constructors.js & enum_all.js working with 'exported' generation strategy.

* Tests function_all.js and interface_all.js working with 'exported' generation strategy.
Warn&debug improvements.

* Test namespace_all.js working with 'exported' generation strategy.

* Tests property_all.js and typedef_all.js working with 'exported' generation strategy.

* 'documented' & 'exported' test cases.
Instrumentation for jsdoc 3.5.5 vs 3.6.3 investigations.

* jsdoc@3.6.3 installation.

* jsdoc@3.6.3 fixes.

* `walk-back.d.ts` typescript declaration.

* `walk-back.d.ts`: application of "tsd-default-export" recommendations.
See: https://github.com/Alexis-ROYER/tsd-default-export/blob/master/README.md

* Corrections to @englercj’s remarks.

* Fix merge tag 'v2.5.0' into export-default
'exported' tests were not executed due to a false trailing 'r' after `generationStrategy` in `test/lib/index.ts`.

* Corrections to @englercj’s remarks.

Co-authored-by: Lukas Hollaender <lukas.hollaender@yworks.com>
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