-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
improve typescript documentation: enums & aliases! #1982
Conversation
remove page arg from renderBlock
createDefaultRenderers()Preview: documentation |
ok i figured it out! must set tsconfig path so it knows how to compile our code. palantir/documentalist#58 |
tsconfigPath option fixes interface inheritance!!!Preview: documentation |
Merge branch 'master' of github.com:palantir/blueprint into gg/docs-typescriptPreview: documentation |
); | ||
}; | ||
ApiHeader.contextTypes = DocumentationContextTypes; | ||
ApiHeader.displayName = "Docs.ApiHeader"; |
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.
bleh I prefer using React classes over SFCs, especially since code like these 2 lines looks silly. there are literally no benefits to SFCs in practice, and it's easier to "upgrade" components to be more complex as needed when they're classes. but it doesn't have to block this PR
</div> | ||
<small className="docs-package-name"> | ||
<a href={GITHUB_URL + data.fileName.slice(3)} target="__blank"> | ||
@blueprintjs/{data.fileName.split("/", 2)[1]} |
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 needs to be configurable... you're in the docs-theme package, not docs-app
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.
oh snap so true. i think i need to add a url
field to the DM data... typedoc already provides one that even links to line number.
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.
oops this is not done. not sure how to support it either...
return `${title} ${array.join(", ")}`; | ||
} | ||
|
||
const GITHUB_URL = "https://github.com/palantir/blueprint/tree/master/packages/"; |
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.
same here, this needs to be configurable
} | ||
} | ||
|
||
// HACKHACK support `code` blocks until we get real markdown parsing in ts-quick-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.
we don't use ts-quick-docs anymore
} | ||
} | ||
|
||
// HACKHACK support `code` blocks until we get real markdown parsing in ts-quick-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.
another reference to ts-quick-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.
also why is this code duplicated? make it a utility function
heading: tags.Heading, | ||
interface: tags.TypescriptExample, | ||
page: () => null, | ||
// TODO: @see |
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.
what?
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.
support the @see
tag
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'll address this in the next PR
</div> | ||
<small className="docs-package-name"> | ||
<a href={this.props.sourceUrl} target="_blank"> | ||
@blueprintjs/{this.props.fileName.split("/", 2)[1]} |
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.
@adidahiya thoughts on how to make this configurable? perhaps a new context function getPackageName(entry: ITsDocBase)
and some prop on Documentation
?
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.
or renderViewSourceLinkText(entry: ITsDocBase): React.ReactNode
which defaults to simply returning "View source"
(render...Text cuz the href itself is handled by sourceUrl
)
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.
yeah I like the latter approach. default to "View source" and don't do anything too fancy with package paths in this docs-theme package (we can be fancier in docs-app).
markdownCode utilPreview: documentation | landing | table |
Documentation renderViewSourceLinkText propPreview: documentation | landing | table |
Merge branch 'develop' of github.com:palantir/blueprint into gg/docs-typescriptPreview: documentation | landing | table |
@adidahiya ok I think this is ready to go 🚢 |
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.
minor comments. -1 for the last one
private renderTags(entry: ITsEnumMember) { | ||
const { flags: { isDeprecated } } = entry; | ||
return ( | ||
(isDeprecated === true || typeof isDeprecated === "string") && ( |
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.
not a fan of implicit type coercion and complicated JS inside JSX
return ( | ||
<> | ||
{!isOptional && <Tag children="Required" className={Classes.MINIMAL} intent={Intent.SUCCESS} />} | ||
{(isDeprecated === true || typeof isDeprecated === "string") && ( |
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.
same here
packages/docs-theme/src/tags/css.tsx
Outdated
); | ||
}; | ||
CssExample.contextTypes = DocumentationContextTypes; | ||
CssExample.displayName = "Docs.CssExample"; |
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.
prefer making this a class for consistency, since it's complex enough (it requires a helper render function)
@@ -19,15 +19,15 @@ export class ReactDocsTagRenderer { | |||
* it to an actual component class in the given map, or in the default map which contains | |||
* valid docs components from this package. Provide a custom map to inject your own components. | |||
*/ | |||
public render: TagRenderer = ({ value: componentName }, key) => { | |||
public render: React.SFC<ITag> = ({ value: componentName }) => { |
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.
why limit this to SFCs? prefer React.ComponentType<ITag>
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 is the type of this render
function, not the type of the component, so it's actually correct here. but i'll make the change elsewhere to support SFCs in docs components.
see 958dfbd
tag renderers can be SFCs or classesPreview: documentation | landing | table |
Changes proposed in this pull request:
There's a lot going on here, sorry! I had a good time over break hacking on the docs renderers.
React.SFC<ITag>
, none of that awkward class with arender
method.@reactExample
and@reactDocs
, which still use a class cuz their data comes from outside documentalistcontext
toDocumentation
root component which exposesrenderBlock
,renderType
, andgetDocsData
functions, rather than passing huge data blobs around through props.@interface
tag now supports enums and type aliases too!!! (this is not demonstrated in the docs yet...)Documentation
requires Markdown data, optionally accepts Typescript and KSS data.Reviewers should focus on:
typescript
data now includes non-interface-y things (namely enums and type aliases). should we rename the@interface
tag to@typescript
to match@css
?