Skip to content

Docs: jsdoc example using build.jobs and build.tools #9241

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

Merged
merged 2 commits into from
May 19, 2022

Conversation

humitos
Copy link
Member

@humitos humitos commented May 18, 2022

Expand our build customization page with an example for jsdoc.

See https://test-builds.readthedocs.io/en/jsdoc/ as example of usage.

Expand our build customization page with an example for jsdoc.
@humitos humitos requested a review from a team as a code owner May 18, 2022 14:10
nodejs: "16"
jobs:
post_install:
- npm install -g jsdoc
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this is missing the part where you actually implement it in Sphinx? Could be neat to include to make it more copy-pastable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yeah. I wasn't sure if this page is the right place for that. I felt that I was contaminating it with a lot of code that it's outside the scope of build.jobs / build customization. Probably, the full example fits better on a blog post or a guide explaining the full process to document Javascript documentation. We could link to that post/guide from here.

Copy link
Contributor

@agjohnson agjohnson May 18, 2022

Choose a reason for hiding this comment

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

Yeah, agreed, I'd probably rather have a guide for this. It's fairly common to use sphinx-js for this, which is possible to use without build commands even:

https://github.com/readthedocs/ext-theme/blob/main/.readthedocs.yaml
https://github.com/readthedocs/ext-theme/blob/main/docs/conf.py

There's additional caveats, like needing a supported version of jsdoc/typedoc. And also how to write documentation and configure jsdoc to document a source tree of JS files is probably the largest point of that guide. I think everything in one place is probably the most approachable format for a guide like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if we can generalize this example, maybe it's wise to point out npm ci as well. This is probably what the user wants ultimately, for reproducible builds, so would be a good suggestion for us to give.

Suggested change
- npm install -g jsdoc
- npm ci
- npm install -g jsdoc

Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

Perhaps this is better off just as a generalized example. There is a lot to say about actually using sphinx-js and jsdoc together, especially once you get past a basic example and on to documenting a full JS library.

I've wanted to write up a more complete guide around this. Perhaps this guide should be my doc addition focus one of the next sprints. I found the sphinx-js docs not super helpful, and struggled with a few configuration pieces to make everything work.

Comment on lines 201 to 202
Document your code with ``jsdoc``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be better off generalized, rather than specific to jsdoc. There is a lot more to say about jsdoc usage, and duplicating that here will probably guide users to the wrong guide content.

Suggested change
Document your code with ``jsdoc``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Install Node.js dependencies
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Copy link
Member Author

Choose a reason for hiding this comment

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

I like this idea, 💯

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It's possible to make usage of ``jsdoc`` to document your Javascript code directly from your source code.
To setup it, you need to first define the version of ``nodejs`` you want to use and also install ``jsdoc`` as shown below:
Copy link
Contributor

Choose a reason for hiding this comment

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

If generalizing this, the copy here would need to be tweaked. But generally, noting to use the official terminology:

Suggested change
To setup it, you need to first define the version of ``nodejs`` you want to use and also install ``jsdoc`` as shown below:
To setup it, you need to first define the version of Node.js you want to use and also install ``jsdoc`` as shown below:

nodejs: "16"
jobs:
post_install:
- npm install -g jsdoc
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if we can generalize this example, maybe it's wise to point out npm ci as well. This is probably what the user wants ultimately, for reproducible builds, so would be a good suggestion for us to give.

Suggested change
- npm install -g jsdoc
- npm ci
- npm install -g jsdoc

@humitos
Copy link
Member Author

humitos commented May 19, 2022

Thanks for the feedback on this. I will update the documentation to make it more generalized as Anthony suggested. I think that's the right step. After that, we can write a guide / post for a specific use case of this feature together with jsdoc 👍🏼

@humitos
Copy link
Member Author

humitos commented May 19, 2022

I updated the PR to make it more generalized, and I like it more. Let me know if it's ready to merge.

I also opened #9247 to track the writing of a blog post / guide for jsdoc.

Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

💯

@humitos humitos merged commit 6247f9f into main May 19, 2022
@humitos humitos deleted the humitos/jsdoc-example branch May 19, 2022 18:38
@ericholscher
Copy link
Member

Will be curious to see if we get any SEO traffic for this page 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants