-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation in template files (#6)
provides possibility to add documentation in templates with a twig-comment: {#TWIG_DOC ... TWIG_DOC#}
- Loading branch information
1 parent
7125d6e
commit f3c1607
Showing
44 changed files
with
1,265 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
/var/ | ||
/vendor/ | ||
/report/ | ||
.phpunit.cache | ||
.phpunit.result.cache | ||
composer.lock | ||
.php-cs-fixer.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
## Configuring the bundle | ||
|
||
When you do not want to customize, you do not need any config file. | ||
|
||
The bundle provides following defaults: | ||
|
||
```yaml | ||
twig_doc: | ||
doc_identifier: TWIG_DOC | ||
directories: | ||
- '%twig.default_path%/components' | ||
categories: | ||
- name: Components | ||
``` | ||
### Directories | ||
By default, the bundle looks for your components in this directory: `%twig.default_path%/components` | ||
|
||
You can provide additional directories in the config-file: | ||
|
||
```yaml | ||
twig_doc: | ||
directories: | ||
- '%twig.default_path%/snippets' | ||
- '%kernel.project_dir%/resources/components' | ||
``` | ||
|
||
### Documentation identifier | ||
|
||
By default, the bundle uses this identifier: `TWIG_DOC` | ||
|
||
To use another one: | ||
|
||
```yaml | ||
twig_doc: | ||
doc_identifier: 'MY_DOC_IDENTIFIER' | ||
``` | ||
|
||
In your component template, you can then mark up your documentation in the template: | ||
|
||
```twig | ||
{#MY_DOC_IDENTIFIER | ||
title: My component | ||
... | ||
MY_DOC_IDENTIFIER#} | ||
<div class="fancy-component"></div> | ||
``` | ||
|
||
### Categories | ||
|
||
The bundle groups components into categories and optionally into sub-categories. | ||
|
||
Example: | ||
|
||
```yaml | ||
twig_doc: | ||
categories: | ||
- name: Buttons | ||
sub_categories: | ||
- Action | ||
- Submit | ||
- name: Headings | ||
- name: Alerts | ||
... | ||
``` | ||
|
||
The default category is always merged into the configuration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
### Component Configuration | ||
|
||
You have two possibilities to let the bundle know of your components: | ||
|
||
1. Directly in the template of the component itself (you should stick to this) | ||
2. In the config file | ||
|
||
You can use both possibilities, but it is recommended to use only one to avoid scattering documentation over different places. | ||
|
||
When you do not provide a category for the component, it will be added to the default-category. | ||
|
||
#### In Template | ||
|
||
We "abused" the comment tag from twig to allow the component configuration directly in the template. | ||
This won't hurt twig at all as comments are totally ignored by the twig-parser. | ||
|
||
When providing the config in the template, you do not need to provide the name, this is automatically resolved from the template file. | ||
|
||
```twig | ||
{#TWIG_DOC | ||
title: Fancy Button | ||
description: This is a really fancy button | ||
category: Buttons | ||
tags: | ||
- button | ||
parameters: | ||
type: String | ||
text: String | ||
variations: | ||
primary: | ||
type: primary | ||
text: Hello World | ||
secondary: | ||
type: secondary | ||
text: Welcome to Hell! | ||
#TWIG_DOC} | ||
<button class="btn btn-{{ type }}">{{ text }}</button> | ||
``` | ||
|
||
#### Config file | ||
|
||
This is only recommended for small sets of components. | ||
|
||
The bundle tries to resolve the path of the template in a compiler pass based on the name of the component. | ||
|
||
E.g.: name: Button -> bundle looks for a Button.html.twig | ||
|
||
For this to work, you need to ensure that your components are unique among all configured directories. | ||
|
||
```yaml | ||
... | ||
components: | ||
- name: Button | ||
title: Fancy Button | ||
description: This is a really fancy button | ||
category: Buttons | ||
tags: | ||
- button | ||
parameters: | ||
type: String | ||
text: String | ||
variations: | ||
primary: | ||
type: primary | ||
text: Hello World | ||
secondary: | ||
type: secondary | ||
text: Welcome to Hell! | ||
``` | ||
Alternatively, you can provide a path for your component in the configuration (parameters are resolved automatically): | ||
```yaml | ||
... | ||
components: | ||
- name: Button | ||
path: '%twig.default_path%/snippets/FancyButton.html.twig' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Usage | ||
|
||
TODO | ||
- screenshots of UI | ||
- searching |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.