-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
docs: Add JSDoc for all events #3313
base: main
Are you sure you want to change the base?
Conversation
The official JSDoc events is confusing and poorly documented, so this is really just “tagging” where event are listened for, and where they are emitted. …That said, I think it’s a good start towards documenting the public API of Eleventy’s internals. JSDocs like this—even when they exist only in the source—will be particularly helpful for plugin authors who want to explore what they are able to do, and how they might do it.
What does this add, practically? More documentation in an eventual generated JSDoc website? |
I've touched on this in #3296. As of now, unless the roadmap specifies otherwise, Typings should be utilizing a standardized const Eleventy = require("@11ty/eleventy");
// Create an instance
const eleventy = new Eleventy(); Developers using the default class export (i.e., programmatic control) can benefit from JSDocs defined types or alternatively by pulling in a specific module.exports = function(eleventyConfig) {} Currently, developers leveraging JSDoc annotations need to use the following approach: /**
* @type {import('@11ty/eleventy')}
*/
module.exports = function(eleventyConfig) {} This method is cumbersome and not necessarily intuitive for several reasons:
|
@zachleat That was my plan, yeah. I was hoping to eventually steer this (and other JSDoc work) into a types file that can be used for autocompletion.
@panoply Can you explain to me what that means? Most of all, I have been trying to get documentation PRs merged for some time. To make it easier, I have been trying to submit smaller JSDoc PRs like this one, focused on a particular topic or part of the codebase. I don’t particularly enjoy reading or writing TypeScript, but I love the autocompletion it offers in editors, which is why I was hoping to go with the “typings generated from JSDocs” approach I mentioned above to @zachleat.
I’m not so sure about this one. There has been lots of discussion about JSDoc’s ability to work with the TS Language Server for years. Check out:
I’ve been happy to dive in and document the changes. (Unless, of course, I am taking on a fool’s errand. … …Am I?) The most important parts of a JSDoc—as far as I know—are an overall brief descriptive summary, and the types and descriptions of params (and return types). These live directly below the JSDoc. I don’t think it’s any more difficult to document in JSDoc than it is to rewrite everything in TypeScript. I do agree the chance for divergence is greater if you try to document everything in greater detail than what I’ve been attempting. I was hoping to work towards a minimalist-but-useful amount of annotation.
Yeah, I was toying with generating this stuff, too. I was just trying to keep my PRs as small an easy-to-review as I could. Maybe I’ve failed… 🤕 Anyway, @panoply: Where (or how) do you think my efforts be most likely to be accepted? |
@panoply Okay! So, what I got from the referenced issue with Do I have that correct? |
@Zearin, I apologize for not providing a more thorough response in previous comments. I had a busy weekend. To elaborate: using You mentioned:
Using JSDoc annotations has limitations, particularly in auto-typing plugins that expose declarations. For example, this section demonstrates how it’s currently possible with 11ty.ts. From what I understand, this PR aims to provide better references of internal events and additional methods in the Eleventy API so as to improve end-user understanding. The changes include various annotations, some of which are available in 11ty.ts, such as: While the event API is not fully covered yet, end-users can reference and leverage IntelliSense for plugins or existing methods provided by the FWIW: I wanted to chime in on this PR, aside from the needs-discussion tag, because it relates to issue #3296 and focusing on public-facing references. I am also interested in this topic and been wanting to see some action or better discussion, but given a lot of 11ty users are JS purists, it seems a bit hard to move the needle. In previous discussions on these topics, the general consensus has been to expose typings via JSDoc annotations. While this approach works and can provide IntelliSense (auto-completion) support for developers, I believe JSDoc annotations are more suited for internal use within projects rather than for external usage for project consumers. However, I do understand their value proposition in this context. |
The official JSDoc events is confusing and poorly documented, so this is really just “tagging” where event are listened for, and where they are emitted.
…That said, I think it’s a good start towards documenting the public API of Eleventy’s internals. JSDocs like this—even when they exist only in the source—will be particularly helpful for plugin authors who want to explore what they are able to do, and how they might do it.