-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Generate Documentation in JS / TS #621
Comments
You can do most of that in Markdown as well:
The only thing is missed is TypeScript support. But even this maybe not very hard to implement if anyone wants to have it. Markdown has many other benefits in my opinion, but if you want to use JavaScript, you probably will like Storybook more than Styleguidist. |
@sapegin yeah TS support is probably the biggest loss. Being tied to extra dependencies and frameworks is not ideal and taking devs out of their familiar environment (ts / js) to work in free text doesn't sound like the best way to go for us. Unfortunately storybook doesn't fit our use case for a number of other reasons. If we forked the repo and developed the option to declare docs in code would that be considered for merging into the main repo? Cheers! |
This may be a good addition of course if it has a good API and won’t complicate the code much ;-) Do you already have any ideas on the API? Can we somehow reuse it for interoperability with Storybook? (That would be amazing feature!) |
I'll need to dig into it a bit but my gut thought is to just use a naming scheme to find the documentation and then just some react components to wrap the necessary pieces of documentation. For example: Filename: import * as React from 'react';
import { Section, Copy, RenderedComponent } from 'react-styleguidist';
import MyButton from './MyButton';
import * as React from 'react';
import { Section, Copy, RenderedComponent } from 'react-styleguidist';
import MyButton from './MyButton';
export default () => {
return (
<Section>
<Copy>
Here I write some assocatiated copy for my component
</Copy>
<RenderedComponent>
{/*
everything inside rendered component will get rendered in
an editable sandbox
*/}
<MyButton />
</RenderedComponent>
</Section>
);
}; |
I’d propose a different approach: decouple current Markdown parsing logic and create a common format fur examples that Styleguidist will use internally. So we could create different “loaders” for Markdown, Storybook and something that you want. So I’d rewrite you example like this: import * as React from 'react';
import MyButton from './MyButton';
export default () => {
return [
'Here I write some assocatiated copy for my component',
<MyButton />,
{
type: 'example',
options: { static: true },
code: <MyButton />
}
];
}; The first two are shortcuts to the full form in the last example. |
@sapegin what are the benefits? |
|
Did you end up creating this fork? I have been trying a styleguide-first approach to development, but the missing type safety and other editor features makes it more difficult than it could be. |
Now that the |
@Chr1stian in order to make I like the idea and might investigate. |
@elevatebart Making compilers customizable would be a great feature and like not hard to implement as soon as we find a good API. The difficulty here is that it's not just Buble (which we need to change to Babel anyway) but also things like transpiling imports and wrapping code in a Fragment. All this should be customizable but at the same time easy to reuse. So extracting them to separate packages might be a good idea ;-) |
By the way for loading TypeScript a Babel plugin might be enough if it's smaller. |
Here is a couple of links for inspiration of a In vue-styleguidist, we precompile examples in the examples loader then load the compiler asynchronously in the component when users make a change to the code. This would solve in part the weight issue. |
This looks very interesting! And we won't need to transpile imports once we use Babel. |
Is there anyway to declare documentation for components in JS (or TS) rather than markdown?
Having free-text (md) feels quite chaotic - writing the documentation in JS would enable us to do linting, import & share stub data, testing and have typesafety in TS.
The text was updated successfully, but these errors were encountered: