-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Explain how to use JSDoc with 11ty config file #2033
Comments
@wdsrocha, based on this type definition, does this work? /** @type {import('@11ty/eleventy').TemplateConfig~TemplateConfig~config} */
module.exports = function (config) {
// do something
} |
It does not, @paulshryock. But I've noticed that the JSDoc is missing in the build files (that is |
But I just found out that this seems to work const UserConfig = require("@11ty/eleventy/src/UserConfig");
/** @param {UserConfig} config */
module.exports = function (config) {
config.addPassthroughCopy("./src/*.css"); // this was autocompleted
return {
dir: {
input: "src",
output: "dist",
},
};
}; I'm just not sure if UserConfig is a subset of what this configuration parameter is supposed to be |
This seems correct. |
Shouldn't be related. I think this project only uses JSDoc to provide type definitions for those using TypeScript. But I don't think the actual documentation site is intended to be built. |
I meant Docs addition looks okay to me as well, though I'm not sure if there's a standard way that this type of note (about TypeScript/types) is added anywhere else in the Docs. If there is, then this note should be consistent with whatever convention is normally used. |
I opened #2091 to hopefully make this easier for consumers. With that you can import from the package without knowing the internal paths of things: /** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
module.exports = function (eleventyConfig) { ... } |
This seems like the leanest method right now, which is fine once you know about it: /** @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig */
module.exports = (eleventyConfig) => { |
This is the one I use (that I don't remember which repo/article I "borrowed" it from): /**
* @typedef {import('@11ty/eleventy/src/UserConfig')} EleventyConfig
* @typedef {ReturnType<import('@11ty/eleventy/src/defaultConfig')>} EleventyReturnValue
* @type {(eleventyConfig: EleventyConfig) => EleventyReturnValue}
*/
module.exports = function (eleventyConfig) { ... }; |
@pdehaan what does the return type do? :o |
@FunctionDJ https://www.11ty.dev/docs/config/ The return object lets you define your config options (like input/output/include/layout/data directories, template engines for data/markdown/html files, supported template engines, and a handful of other things). |
@pdehaan oh wow i've done a bunch of crazy customisation using shortcodes etc but never needed the actual regular config object. |
#2091 is merged! Preliminary docs are building to https://www.11ty.dev/docs/config/#type-definitions |
|
Hi 👋
Some time ago @Ryuno-Ki added JSDoc support in the following PR: #720
My question is: how to use it? It might be silly and something that anyone with basic knowledge in JSDoc knows how to do, but I have no clue on how to make it work. I've tried:
Here is my last attempt
If this isn't something straightforward and there is anything that I can do to help, please tell me. Thanks!
The text was updated successfully, but these errors were encountered: