5 lines
12 KiB
JSON
5 lines
12 KiB
JSON
|
{
|
||
|
"id": "guide/schematics",
|
||
|
"title": "Generating code using schematics",
|
||
|
"contents": "\n\n\n<div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/aio/content/guide/schematics.md?message=docs%3A%20describe%20your%20change...\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n</div>\n\n\n<div class=\"content\">\n <h1 id=\"generating-code-using-schematics\">Generating code using schematics<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/schematics#generating-code-using-schematics\"><i class=\"material-icons\">link</i></a></h1>\n<p>A schematic is a template-based code generator that supports complex logic.\nIt is a set of instructions for transforming a software project by generating or modifying code.\nSchematics are packaged into <a href=\"guide/glossary#collection\">collections</a> and installed with npm.</p>\n<p>The schematic collection can be a powerful tool for creating, modifying, and maintaining any software project, but is particularly useful for customizing Angular projects to suit the particular needs of your own organization.\nYou might use schematics, for example, to generate commonly-used UI patterns or specific components, using predefined templates or layouts.\nYou can use schematics to enforce architectural rules and conventions, making your projects consistent and inter-operative.</p>\n<h2 id=\"schematics-for-the-angular-cli\">Schematics for the Angular CLI<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/schematics#schematics-for-the-angular-cli\"><i class=\"material-icons\">link</i></a></h2>\n<p>Schematics are part of the Angular ecosystem. The <a href=\"guide/glossary#cli\">Angular CLI</a> uses schematics to apply transforms to a web-app project.\nYou can modify these schematics, and define new ones to do things like update your code to fix breaking changes in a dependency, for example, or to add a new configuration option or framework to an existing project.</p>\n<p>Schematics that are included in the <code>@schematics/angular</code> collection are run by default by the commands <code>ng generate</code> and <code>ng add</code>.\nThe package contains named schematics that configure the options that are available to the CLI for <code>ng generate</code> sub-commands, such as <code>ng generate component</code> and <code>ng generate service</code>.\nThe subcommands for <code>ng generate</code> are shorthand for the corresponding schematic. You can specify a particular schematic (or collection of schematics) to generate, using the long form:</p>\n<code-example language=\"bash\">\nng generate my-schematic-collection:my-schematic-name\n</code-example>\n<p>or</p>\n<code-example language=\"bash\">\nng generate my-schematic-name --collection collection-name\n</code-example>\n<h3 id=\"configuring-cli-schematics\">Configuring CLI schematics<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"guide/schematics#configuring-cli-schematics\"><i class=\"material-icons\">link</i></a></h3>\n<p>A JSON schema associated with a schematic tells the Angular CLI what options are available to commands and subcommands, and determines the defaults.\nThese defaults can be overridden by providing a different value for an option on the command line.\nSee <a href=\"guide/workspace-config\">Workspace Configuration</a> for information about how you can change the generation option defaults for your workspace.</p>\n<p>The JSON schemas for the default schematics used by the CLI to generate projects and parts of projects are collected in the package <a href=\"https://github.com/angular/angular-cli/tree/master/packages/schematics/angular\"><code>@schematics/angular</code></a>.\nThe schema describes the options available to the CLI for each of the <code>ng generate</code> sub-commands, as shown in the <code>--help</code> output.</p>\n<h2 id=\"developing-schematics-for-libraries\">Developing schematics for libraries<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\
|
||
|
}
|