Skip to content

Commit

Permalink
Update enricher docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dirx committed Nov 21, 2020
1 parent 67bf1d0 commit 914e34f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ It´s a thin layer around [phpdocumentor/reflection](https://github.com/phpDocum
## Runtime Requirements

* PHP ^7.4
* optional
* json extension to enrich `phploc`
* simplexml extension to enrich `clover` coverage data

Suggested:

* json extension to enrich `phploc` data
* simplexml extension to enrich `clover` coverage data

## Quick Start

Expand Down
30 changes: 22 additions & 8 deletions docs/enrichers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

## How do they work?

Enrichers can add extra data to any data holder like `Project` or `Element` items (File, Class, Interface, Trait, Method, Function, Constants and Function/Method Arguments).

* Each Enricher must implement `Klitsche\Dog\Enrichers\EnricherInterface`
* Recommendation: for a customized enricher extend the abstract class `Klitsche\Dog\Enrichers\Enricher`
* Data holders must implement `Klitsche\Dog\Enrichers\DataAwareInterface`
* This extra data can be scalar values or objects
Enrichers can add extra data to a data holder. Supported data holders are:

* `Project`
* `File`
* `Class_`
* `Trait_`
* `Interface_`
* `Constant`
* `Property`
* `Method`
* `Function_`
* `Argument`

Enrichers come with a 3 phase process:

Expand All @@ -30,7 +36,7 @@ In this Phase enricher can add data be calling `setData(string $id, $value)` on
Using the enricher id here is best practise.

!!! Note
All enricher first visit the project and then all enricher visit the elements.
All enricher first visit the project and then the elements.

## Access Data in Templates

Expand Down Expand Up @@ -93,4 +99,12 @@ enrichers:
file: phploc.json
```

See for more details on phploc.
See for more details on phploc.

## Custom enricher

* A Enricher must implement `Klitsche\Dog\Enrichers\EnricherInterface`
* Best practise: enricher extends the abstract class `Klitsche\Dog\Enrichers\Enricher`
* Data holders must implement `Klitsche\Dog\Enrichers\DataAwareInterface`
* Best practise: use its enricher id to add extra data to data holders
* Extra data can be scalar values or objects
4 changes: 3 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ markdown_extensions:
- footnotes
- meta
- smarty
- attr_list
- toc:
permalink: true
- pymdownx.arithmatex
Expand All @@ -32,7 +33,8 @@ markdown_extensions:
- pymdownx.critic
- pymdownx.details
- pymdownx.emoji:
emoji_generator: !!python/name:pymdownx.emoji.to_svg
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
- pymdownx.highlight:
# fixes copy paste support
css_class: codehilite
Expand Down

0 comments on commit 914e34f

Please sign in to comment.