-
Notifications
You must be signed in to change notification settings - Fork 715
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
Conversation
@@ -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": { |
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 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", |
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.
I think we can remove this once all packages are converted
.title > :not(:last-child) { | ||
margin-right: 12px; | ||
} | ||
.description > :global(p) { |
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.
: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; |
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 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" /> |
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.
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({ |
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.
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'}> |
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.
noting the only one that goes to a new /docs
page versus .html
</li> | ||
</ul> | ||
|
||
<ApiTable anchorId="Axis" docgenInfo={Axis.__docgenInfo} /> |
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.
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
e4ea82a
to
163ae5a
Compare
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
📝 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 theAxis
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:
doc
script is invoked, which runs abash
node
script that reads in the files for the package and generates anapi.md
filepackage/docs/*
, theapi.md
file is concatenated withdescription.md
andinstall.md
files to createdocs.md
docs.md
is used to create a static.html
page that is rendered by thenext 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 thenext js
app asreact
components.Specifically this PR makes the following changes:
next
webpack
config to include thereact-docgen-typescript-loader
which annotates components with any defined typesApiTable
to render prop types + descriptions + default values (mirroring the oldapi.md
)DocPage
component to render the docs for a given package/docs
page tovx
ecosystem more understandablepages/docs/Axis
page usingDocPage
ApiTable
.html
links in/docs
to point to this new doc pagedocs
script, and oldvx-axis/docs/*.md
filesOverall 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
After
@hshoff @kristw