-
Notifications
You must be signed in to change notification settings - Fork 664
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: sprucing up docs, esp. reference doc generation #2070
Conversation
…o docs folder, lint during docs CI, tweak generated reference documentation styles (tables instead of lists where possible).
*/ | ||
function packageReferenceOptions(pkg) { | ||
return { | ||
classPropertiesFormat: 'table', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The various *Format
properties and setting them to table
, I think, is nicer than the default of a bulleted list - makes better use of horizontal space, and as we add more kinds of information to our source code comments / JSdocs, these should show up as separate columns. E.g. if we add an @examples
JSDoc tag to some method docs, that will show up as a new column in the generated docs.
An example of a table this setting outputs:
![Screenshot 2024-10-03 at 3 50 52 PM](https://private-user-images.githubusercontent.com/52645/373395096-c3809827-21a0-41e1-b43f-cc0c35d29edb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4Nzg0MTMsIm5iZiI6MTczOTg3ODExMywicGF0aCI6Ii81MjY0NS8zNzMzOTUwOTYtYzM4MDk4MjctMjFhMC00MWUxLWI0M2YtY2MwYzM1ZDI5ZWRiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDExMjgzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlhOTE1ZTg4ODZjNDNhOWM0NjcyNDE0NWU4NDRmZTFlZGQ1YzU5YmJlZDczODM1NmNmNTA5MTMyY2Y3Y2Q3YzkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.GPxngLi3fcG2R0HUulGomagd83Qihhhn0CKy3BG_aCg)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! I agree the table is the way to go 🎉
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2070 +/- ##
=======================================
Coverage 91.74% 91.74%
=======================================
Files 38 38
Lines 10081 10083 +2
Branches 631 631
=======================================
+ Hits 9249 9251 +2
Misses 820 820
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more. |
docs/package.json
Outdated
"start": "docusaurus start", | ||
"build": "docusaurus build", | ||
"start": "TYPEDOC_WATCH=true docusaurus start", | ||
"build": "TYPEDOC_WATCH=false docusaurus build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followed these docs to set up proper TypeScript reference doc re-generation watching: https://typedoc-plugin-markdown.org/plugins/docusaurus/watch-mode
@@ -9,59 +9,59 @@ export enum LogLevel { | |||
} | |||
|
|||
/** | |||
* Interface for objects where objects in this package's logs can be sent (can be used as `logger` option). | |||
* Logging interface exposing different methods to log at different {@link LogLevel}s. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -94,53 +95,35 @@ export class ConsoleLogger implements Logger { | |||
return this.level; | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd, docs building seems to fail in CI but runs fine for me locally 🤔 need to investigate more. |
@@ -31,6 +31,22 @@ jobs: | |||
run: npm ci | |||
working-directory: ./docs | |||
|
|||
- name: Install sub-package dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the docs sidebar generation relies on importing and parsing TypeScript source of each sub-package we wish to document, we need to pull in the dependencies of each sub-package before building can begin.
@@ -32,10 +58,12 @@ const config = { | |||
/** @type {import('@docusaurus/preset-classic').Options} */ | |||
({ | |||
docs: { | |||
sidebarItemsGenerator: async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leveraged this documented approach here: https://typedoc-plugin-markdown.org/plugins/docusaurus/sidebar#injecting-into-autogenerated-sidebar
out: "./content/reference/webhook", | ||
} | ||
] | ||
...PACKAGES.map((pkg) => ['docusaurus-plugin-typedoc', packageReferenceOptions(pkg)]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRYing things up here
docs/sidebars.js
Outdated
type: 'doc', | ||
id: `reference/${pkg}/index`, | ||
}, | ||
items: await waitAndImportFile(`./content/reference/${pkg}/typedoc-sidebar.cjs`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue I saw playing around with the docs is that sometimes, as part of docs re-generation, I would get MODULE_NOT_FOUND
errors where the sidebar generation was executing, and the generated typedoc files for each sub-package was missing. I think this has something to do with the docusaurus lifecycle: plugins we use, like typedoc, are still executing will docusaurus is trying to generate the sidebar. This lifecycle is a bit unclear to me. In any case, to prevent this error, I rewrote this part so that require
ing the relevant sub-package's generated typedoc only happens once the generated file is actually present. It seems to have addressed the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the file pretty much guaranteed to generate within 50ms or should we increase this for flexibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to say 😢 initially, at least when running locally, I had this set to 200 and things worked fine. After a while I decided to drop to 50 to see if that changed behaviour, but that also seems to work locally 🤷
'packages/rtm-api', | ||
'packages/webhook', | ||
'packages/socket-mode', | ||
{ type: 'doc', id: 'getting-started' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving to the more fine-control approach of providing our own asynchronous sidebar generator function, for some reason, requires the output of the function to be the more verbose list-of-objects for sidebar items - I'd get errors otherwise. So, had to move away from the the convenience string items 🤷
docs/sidebars.js
Outdated
}, | ||
], | ||
label: 'API Reference', | ||
items: apiReferenceItems, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part was also DRYed up a bit
@@ -4,7 +4,7 @@ | |||
* work well for content-centric websites. | |||
*/ | |||
|
|||
:root { | |||
:root { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purely linter fixes
import Translate from '@docusaurus/Translate'; | ||
import Heading from '@theme/Heading'; | ||
export default function NotFoundContent({className}) { | ||
import clsx from 'clsx'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purely linter fixes
import React from 'react'; | ||
import {translate} from '@docusaurus/Translate'; | ||
import {PageMetadata} from '@docusaurus/theme-common'; | ||
import { translate } from '@docusaurus/Translate'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linter fixes only here
@@ -1,20 +1,20 @@ | |||
/* Color variables */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linter fixes only here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent work and LGTM 😄 left a few questions, mostly for my learning purposes 🧠
If we've led you astray, please let us know. We'll do our best to get things in order. | ||
|
||
<Translate id="theme.NotFound.p1" description="The first paragraph of the 404 page"> | ||
If we've led you astray, please let us know. We'll do our best to get things in order. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be more of a copy nit for a follow up PR, but should we include some sort of link or CTA here so folks can leave feedback on the docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great call. @hello-ashleyintech perhaps you can help me, a total React noob, here: I tried wrapping the "please let us know" text in an <a href=""></a>
tag and link to this repo's issue creation, but I get a, I think, React error 😢
How.. does one do links in React? 👶
![Screenshot 2024-10-04 at 9 55 36 AM](https://private-user-images.githubusercontent.com/52645/373667267-2a05c429-b0a2-4942-b5f8-29e3b179f04e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4Nzg0MTMsIm5iZiI6MTczOTg3ODExMywicGF0aCI6Ii81MjY0NS8zNzM2NjcyNjctMmEwNWM0MjktYjBhMi00OTQyLWI1ZjgtMjllM2IxNzlmMDRlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDExMjgzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU3NmZjNTRkMWRhMmI5YjIzYmViNzMwMDliNGIwMDhhMDRjMzZkOTM5MWUwMzJiYzE1NmMxMjY3M2JmMGYwOWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ZikwZ3sUY7LUEZnB3DJ-0Wh1JZwBdaOZKH5VCQL7ZIA)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooooh yes! That looks like it might actually be caused by embedding a link in the <Translate>
tag from Docusaurus. It seems like that tag only supports simple strings. The suggested workaround in the docs is to break this into substrings wrapped in the <Translate>
tag - maybe to keep that link as part of the translation it could be something like:
<Translate>If we've led you astray, </Translate><a href=""><Translate>please let us know</Translate></a><Translate>. We'll do our best to get things in order.</Translate>
If that doesn't work though then we might need to just not translate the please let us know
line for now 😬
*/ | ||
function packageReferenceOptions(pkg) { | ||
return { | ||
classPropertiesFormat: 'table', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! I agree the table is the way to go 🎉
docs/sidebars.js
Outdated
type: 'doc', | ||
id: `reference/${pkg}/index`, | ||
}, | ||
items: await waitAndImportFile(`./content/reference/${pkg}/typedoc-sidebar.cjs`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the file pretty much guaranteed to generate within 50ms or should we increase this for flexibility?
… to speed up builds
…t rely on typedoc execution for sidebar entries.
Closing for now -- we ran into build issues with this approach. I'll take another crack at this early next year |
Doing this as part of a an initial pass to learn the docusaurus ropes as I inch towards applying the same thing to bolt-js docs.
I left some in-line comments with screenshots of relevant changes. The big visual change is using tables for API references instead of bulleted lists: I think this is more visually pleasing and also scalable as we add more content to the docs.