This repository has been archived by the owner on Apr 26, 2023. It is now read-only.
Add a generation schematics add-example
to create examples
#11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a generation schematics
add-example
to@vmw/ng-live-docs
to make it easy to create examples for the entity details container. Currently only support examples using components from@vcd/ui-components
.Why this change made?
It currently takes a lot of steps to create an example with its own module, add it to an examples module, and add it to
Documentation.registerDocumentationEntry
.add-example
schematics could generate an empty example component with its module, an examples module which includes all examples for a component/directive and adds them toregisterDocumentationEntry
, and an root examples moduleexamples.module
importing every examples module, which make it easy to import examples toapp.module
.How to use?
Command line:
ng g @vmw/ng-live-docs:add-example --package-name {packageName} --module-name {moduleName} --component-name {componentName} --example-name {exampleName} --display-name {displayName}
packageName
is the package including component to write examples. For example,@vcd/ui-components
.moduleName
is the module importing component.componentName
is a PascalCase or kebab-case string represents the component which this example uses. For example:DatagridComponent
.exampleName
is a PascalCase or kebab-case string represents the name of this example. For example:example-one
.displayName
is the title displayed on example container. For example:This is example one
.Example structure:
Root examples module
examples.module
is underprojectRoot/app
, and imports all the examples module.Examples module
name.examples.module
, which imports all the example using this component, is underprojectRoot/app/components/name
if this example is for component, or is underprojectRoot/app/directives/name
if this example is for directive.Example with its module is under
projectRoot/app/{components|directives}/component-name/example-name
.For example, when adding two
DatagridComponent
's exampleexample-one
andexample-two
, and aShowClippedTextDirective
's exampleexample-three
, the following files are generated:example-one
with its module is underprojectRoot/app/components/datagrid/example-one
with nameDatagridExampleOneExampleModule
.example-two
with its module is underprojectRoot/app/components/datagrid/example-two
with nameDatagridExampleTwoExampleModule
.datagrid.examples.module
which importsDatagridExampleOneExampleModule
andDatagridExampleTwoExampleModule
is underprojectRoot/app/components/datagrid
with nameDatagridExamplesModule
.example-three
with its module is underprojectRoot/app/directives/show-clipped-text/example-three
with nameShowClippedTextExampleThreeExampleModule
.show-clipped-text.examples.module
which importsShowClippedTextExampleThreeExampleModule
is underprojectRoot/app/directives/show-clipped-text
with nameShowClippedTextExamplesModule
.DatagridExamplesModule
andShowClippedTextExamplesModule
is underprojectRoot/app
.Signed-off-by: yumengwu yumengwu95@gmail.com