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

docs(react-docgen-typescript-loader): add proof-of-concept Axis doc page #681

Merged
merged 107 commits into from
May 23, 2020

Conversation

williaster
Copy link
Collaborator

@williaster williaster commented May 8, 2020

📝 Documentation

This PR is the first of several to address #680, to fix auto-generation of package documentation to include our TypeScript annotations, and make the process more efficient. In this PR I've made several updates and created a proof-of-concept for the Axis docs. In subsequent PRs we can update the docs for other packages.

For documentation/others, the current flow for auto-doc generation is as follows:

  • For a given package, the doc script is invoked, which runs a bash node script that reads in the files for the package and generates an api.md file
  • in package/docs/*, the api.md file is concatenated with description.md and install.md files to create docs.md
  • docs.md is used to create a static .html page that is rendered by the next js app under e.g., /static/docs/vx-responsive.html

This is decently complex/lots of pieces, requires a lot of manual check-in work which means docs can become stale, and the script has been broken since the ts rewrite. In this PR I update all of this to be in the next js app as react components.

Specifically this PR makes the following changes:

  • [one time]
    • updates the next webpack config to include the react-docgen-typescript-loader which annotates components with any defined types
    • creates a new ApiTable to render prop types + descriptions + default values (mirroring the old api.md)
    • creates a new DocPage component to render the docs for a given package
    • re-writes the /docs page to
    • group packages functionally to make the vx ecosystem more understandable
    • adds a brief overview of each package to make them more understandable
  • [to be done for each package to be updated]
    • created a new pages/docs/Axis page using DocPage ApiTable
    • updates the static .html links in /docs to point to this new doc page
    • removes docs script, and old vx-axis/docs/*.md files

Overall the result is similar to before, but hopefully will be more manageable. If you have design feedback, or suggestions for package categorization labels lmk 🙏

Before
image

image

After
image

image

@hshoff @kristw

@williaster williaster added this to the v1 milestone May 8, 2020
@@ -38,12 +37,6 @@
"prepare-release": "git checkout master && git pull --rebase origin master && yarn run docs && lerna updated",
"release": "yarn run prepare-release && lerna publish --exact"
},
"lint-staged": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was becoming annoying/very slow 🐌

"marked": "^0.7.0",
"raf": "^3.4.0",
"react": "^15.0.0-0 || ^16.0.0-0",
"react-docgen": "^2.21.0",
"react-docgen": "^5.3.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we can remove this once all packages are converted

.title > :not(:last-child) {
margin-right: 12px;
}
.description > :global(p) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

:global is needed because styled-jsx can't figure out that Markdown creates a p so the style doesn't apply

}
@media (max-width: 600px) {
.doc-container {
flex-direction: column-reverse;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this mostly mirrors the current layout/responsive behavior. noting that sticky is broken in the current docs/I couldn't get it to work here either so removed it

@@ -3,7 +3,7 @@ import React from 'react';
export default () => (
<div className="footer">
<div>
<img src="static/favicon.ico" alt="vx" />
<img src="/static/favicon.ico" alt="vx" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all of these 'static => /static changes are needed for correct URLs within the nested next pages like pages/docs/Axis

import React from 'react';
import { VxPackage } from '../types';

export default function PackageList({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tried to use the same component for /docs and for the package side nav on the /docs/axis page

{!compact && <p>Annotate elements of a chart</p>}
</li>
<li>
<a href="/docs/axis" className={emphasizePackage === 'axis' && 'emphasize'}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

noting the only one that goes to a new /docs page versus .html

</li>
</ul>

<ApiTable anchorId="Axis" docgenInfo={Axis.__docgenInfo} />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

gotta @ts-ignore these, not sure there's a clean way to avoid that 🤔

also noting that we'll have to do this for each component we want to annotate, but I think that's okay, it's not a lot of work

@williaster williaster mentioned this pull request May 12, 2020
williaster and others added 25 commits May 22, 2020 14:52
docs(vx-drag): update to docgen
docs(vx-event): convert to docgen
docs(vx-geo): convert to docgen
docs(vx-glyph): update to codegen
docs(vx-gradient): update to docgen
docs(vx-grid): update to docgen
docs(vx-group, vx-point): update to docgen
docs(vx-heatmap): convert to docgen
docs(vx-hierarchy, vx-scale): convert to docgen
docs(vx-legend): update to docgen
docs(vx-marker, vx-network): update to docgen
docs(vx-mock-data): update to docgen
docs(vx-pattern, vx-responsive): convert to docgen
docs(vx-shape): convert to docgen
docs(vx-text, vx-tooltip) convert to docgen
docs(vx-threshold): convert to docgen
docs(vx-voronoi): convert to docgen
docs(vx-zoom, vx-vx): convert to docgen
docs(vx-stats): convert to docgen
@williaster williaster merged commit 5919615 into master May 23, 2020
@williaster williaster deleted the chris--fix-docgen branch May 23, 2020 19:55
@williaster williaster mentioned this pull request May 27, 2020
2 tasks
@hshoff hshoff modified the milestones: v1, v0.0.197 Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
V1
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

2 participants