Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@south-paw/storybook-addon-overview-angular
Advanced tools
An addon for Storybook to document your Angular components with
📖 An addon for Storybook to document your Angular components with.
Angular component documentation tool (similar to addon-info which is React only).
This component is heavily based off and inspired by the Atlaskit's component documentation style.
Feel free to ask me questions or make suggestions if there's something missing from the documentation or something isn't clear by raising an issue or contacting me in the Storybook Discord server (@South Paw#7636
) and I'll try help if I can.
@Input
and @Output
documentation).See the live demo for some examples of documented components and check the options out down below 👇
yarn add typedoc -D
npm i typedoc -D
script
to generate your components TypeDoc to your package.json
scripts: { "typedoc": "typedoc --json typedoc.json --exclude **/*.story.* ./test" }
--json typedoc.json
is the json output file location and name--exclude **/*.story.*
means it won't attempt to generate typedocs for storybook stories--exclude **/*.test.*
after the first exclude./test
is the folder which typedoc is going to generate for, I really suggest keeping the scope small rather than 'everything' in your app folder as this seems to affect load times of the Storybook. I usually have scoped it to a /components
folder which holds all my reusable Angular componentsyarn typedoc
or npm run typedoc
typedoc.json
should appear where your --json
file was set to outputscripts: { "storybook": "yarn typedoc && start-storybook" }
yarn add @south-paw/storybook-addon-overview-angular -D
npm i @south-paw/storybook-addon-overview-angular -D
withOverview
addon to your .storybook
config:// .storybook/config.js
import { addDecorator, configure, moduleMetadata } from '@storybook/angular';
import { withOverview, OverviewModule } from '@south-paw/storybook-addon-overview-angular';
// import your generated typedoc file
import typedoc from '../typedoc.json';
// init the withOverview addon with your generated typedoc file
addDecorator(withOverview(typedoc));
// add the required overview components
addDecorator(moduleMetadata({ imports: [OverviewModule] }));
// ...and then your story loading code...
const req = require.context('../test', true, /\.story\.ts$/);
const loadStories = () => req.keys().forEach(filename => req(filename));
configure(loadStories, module);
The addon is disabled
for all stories and must be enabled on a per story basis (unless you enable it globally with addParameters
in the config file)
To enable the overview on a story you would do the following in a story:
storiesOf('Components|Button', module)
.add(
'Overview',
() => ({
// the templated component becomes the example and it's source will be shown too
template: `<my-button [label]="label"></my-button>`,
}),
{
overview: {
enabled: true,
title: 'Button',
filename: 'button/button.component',
exportClass: 'ButtonComponent',
// ... other overview options
},
},
);
Options are simply given to the story as parameters in the overview
key (as above)
enabled
: boolean = falseRequired to enable the overview components on the story.
title
: string = nullThe title of this overview story
filename
: string requiredThe name of the component's file as exported by typedoc.
If you get this wrong, the overview component will render an error which you can use to help you find the right name. The error will list all valid filename
s it has from the TypeDoc.
exportClass
: string requiredThe exported class name of the component.
If you get this wrong, the overview component will render an error which you can use to help you find the right class name. The error will list all valid exportClass
s it has from the TypeDoc.
changelog
: string = nullChangelog you wish to render in the overview component.
If no changelog
is provided, it won't be rendered.
To load a changelog, simply import the .md
file to the story.
Changelog uses h3
headers (###) to deliminate between versions, it will always show the top most version in the .md
file and expects the header to be followed by a list. Here is an example changelog file.
Example of use in story:
import changelog from './changelog.md';
...
storiesOf('Components|Button', module)
.add('Overview', () => ({ template: `<my-button [label]="label"></my-button>` }), {
overview: {
enabled: true,
title: 'Button',
filename: 'button/button.component',
exportClass: 'ButtonComponent',
changelog,
},
});
showTitle
: boolean = trueWhether to show the title in the overview component.
showShortDescription
: boolean = trueWhether to show the short description in the overview component.
This is generated from the first line of the component's documentation block.
showTags
: boolean = trueWhether to show the tags in the overview component.
These are generated from the components documentation block and support markdown.
/**
* Short description about the component.
*
* Long description about the component...
*
* @version 0.0.1
* @string Example String
* @link [Design Spec](http://example.com)
* @key_with_spaces [Another Example](http://example.com)
*/
@Component({
...
})
export class MyCoolComponent { ... }
@version
will become Version
and 0.0.1
will be it's value@string
will become String
and Example String
will be it's value@link
will become Link
and [Design Spec](http://example.com)
will become an a tag with an href of http://example.com
and value of Design Spec
@key_with_spaces
will become Key With Spaces
and [Another Example](http://example.com)
will become an a tag with an href of http://example.com
and value of Another Example
showChangelog
: boolean = trueWhether to show the changelog in the overview component.
If no changelog
is provided, it won't be rendered anyway.
showLongDescription
: boolean = trueWhether to show the long description in the overview component.
This is generated from the everything after the first line of the component's documentation block.
Note: the long description also supports markdown from the component's documentation block.
showUsage
: boolean = trueWhether to show the example usage of the component you're documenting.
showUsageSource
: boolean = falseIf the usage example's source code is open or closed when the story is viewed.
showInputs
: boolean = trueWhether to render the @Input()
members of the component.
showOutputs
: boolean = trueWhether to render the @Output()
members of the component.
showMethods
: boolean = falseWhether to render the public methods of the component's class.
showAccessors
: boolean = falseWhether to render the public get/set
accessors of the component's class.
showInternalProps
: boolean = falseWhether to render the public properties/members of the component's class.
isDebug
: boolean = falseTurn on debugging mode of the overview component.
Helpful to inspect the generated TypeDoc for your inputs and outputs.
Open command line in the project folder and then use any of the following commands
# install dependencies
yarn
# run storybook in dev (localhost:9000)
yarn storybook
# build storybook
yarn storybook:build
# generate typedoc.json file (is also run on `yarn storybook` script)
yarn typedoc
src/
contains all the addon's code and rendering components.test/
contains sample storybook and components for the generated live site.FAQs
An addon for Storybook to document your Angular components with
The npm package @south-paw/storybook-addon-overview-angular receives a total of 3 weekly downloads. As such, @south-paw/storybook-addon-overview-angular popularity was classified as not popular.
We found that @south-paw/storybook-addon-overview-angular demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.