Skip to content

[FEATURE] Add script for generating the class diagram #1297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.php-cs-fixer.cache
/.php_cs.cache
/.phpunit.result.cache
/class-diagram.md
/composer.lock
/coverage.xml
/phpstan.neon
Expand Down
78 changes: 67 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ class Sabberworm\CSS\CSSList\Document#4 (2) {
## Class diagram

```mermaid
%% start of the generated part
classDiagram
direction LR

Expand Down Expand Up @@ -730,76 +731,131 @@ classDiagram
CSSListItem <|-- AtRule: inheritance
AtRule <|.. AtRuleBlockList: realization
CSSBlockList <|-- AtRuleBlockList: inheritance
AtRuleBlockList ..> OutputFormat: dependency
AtRule <|.. AtRuleSet: realization
AtRuleSet ..> OutputFormat: dependency
RuleSet <|-- AtRuleSet: inheritance
CSSList <|-- CSSBlockList: inheritance
Renderable <|-- CSSElement: inheritance
CSSFunction ..> OutputFormat: dependency
CSSFunction ..> ParserState: dependency
ValueList <|-- CSSFunction: inheritance
CSSList ..> AtRuleBlockList: dependency
CSSList ..> AtRuleSet: dependency
CSSElement <|.. CSSList: realization
CSSListItem <|.. CSSList: realization
CSSList ..> CSSNamespace: dependency
CSSList ..> Charset: dependency
CSSList ..> Import: dependency
CSSList ..> KeyFrame: dependency
CSSList ..> OutputFormat: dependency
CSSList ..> ParserState: dependency
Positionable <|.. CSSList: realization
CSSList ..> Selector: dependency
CSSList ..> SourceException: dependency
CSSList ..> UnexpectedTokenException: dependency
Commentable <|-- CSSListItem: inheritance
Renderable <|-- CSSListItem: inheritance
AtRule <|.. CSSNamespace: realization
CSSNamespace ..> OutputFormat: dependency
Positionable <|.. CSSNamespace: realization
CSSString ..> OutputFormat: dependency
CSSString ..> ParserState: dependency
PrimitiveValue <|-- CSSString: inheritance
CSSString ..> SourceException: dependency
CSSFunction <|-- CalcFunction: inheritance
CalcFunction ..> CalcRuleValueList: dependency
CalcFunction ..> ParserState: dependency
CalcFunction ..> RuleValueList: dependency
CalcFunction ..> UnexpectedTokenException: dependency
CalcRuleValueList ..> OutputFormat: dependency
RuleValueList <|-- CalcRuleValueList: inheritance
AtRule <|.. Charset: realization
Charset ..> CSSString: dependency
Charset ..> OutputFormat: dependency
Positionable <|.. Charset: realization
CSSFunction <|-- Color: inheritance
Color ..> OutputFormat: dependency
Color ..> ParserState: dependency
Color ..> Size: dependency
Color ..> UnexpectedTokenException: dependency
Comment ..> OutputFormat: dependency
Positionable <|.. Comment: realization
Renderable <|.. Comment: realization
DeclarationBlock ..> KeyframeSelector: dependency
DeclarationBlock ..> OutputException: dependency
DeclarationBlock ..> OutputFormat: dependency
DeclarationBlock ..> ParserState: dependency
RuleSet <|-- DeclarationBlock: inheritance
DeclarationBlock ..> Selector: dependency
DeclarationBlock ..> UnexpectedTokenException: dependency
CSSBlockList <|-- Document: inheritance
Document ..> OutputFormat: dependency
Document ..> ParserState: dependency
AtRule <|.. Import: realization
Import ..> OutputFormat: dependency
Positionable <|.. Import: realization
Import ..> URL: dependency
AtRule <|.. KeyFrame: realization
CSSList <|-- KeyFrame: inheritance
KeyFrame ..> OutputFormat: dependency
Selector <|-- KeyframeSelector: inheritance
LineName ..> OutputFormat: dependency
LineName ..> ParserState: dependency
ValueList <|-- LineName: inheritance
SourceException <|-- OutputException: inheritance
OutputFormat ..> OutputFormatter: dependency
OutputFormatter ..> Commentable: dependency
OutputFormatter ..> InvalidArgumentException: dependency
OutputFormatter ..> OutputFormat: dependency
Parser ..> Document: dependency
Parser ..> ParserState: dependency
ParserState ..> Anchor: dependency
ParserState ..> Comment: dependency
ParserState ..> Settings: dependency
ParserState ..> SourceException: dependency
ParserState ..> UnexpectedEOFException: dependency
ParserState ..> UnexpectedTokenException: dependency
Value <|-- PrimitiveValue: inheritance
Renderable ..> OutputFormat: dependency
CSSElement <|.. Rule: realization
Commentable <|.. Rule: realization
Rule ..> OutputFormat: dependency
Rule ..> ParserState: dependency
Positionable <|.. Rule: realization
Rule ..> RuleValueList: dependency
RuleContainer ..> Rule: dependency
CSSElement <|.. RuleSet: realization
CSSListItem <|.. RuleSet: realization
RuleSet ..> OutputFormat: dependency
RuleSet ..> ParserState: dependency
Positionable <|.. RuleSet: realization
RuleSet ..> Rule: dependency
RuleContainer <|.. RuleSet: realization
RuleSet ..> UnexpectedValueException: dependency
ValueList <|-- RuleValueList: inheritance
Selector ..> OutputFormat: dependency
Renderable <|.. Selector: realization
Size ..> OutputFormat: dependency
Size ..> ParserState: dependency
PrimitiveValue <|-- Size: inheritance
Exception <|-- SourceException: inheritance
Positionable <|.. SourceException: realization
URL ..> CSSString: dependency
URL ..> OutputFormat: dependency
URL ..> ParserState: dependency
PrimitiveValue <|-- URL: inheritance
UnexpectedTokenException <|-- UnexpectedEOFException: inheritance
SourceException <|-- UnexpectedTokenException: inheritance
CSSElement <|.. Value: realization
Value ..> CSSFunction: dependency
Value ..> ParserState: dependency
Positionable <|.. Value: realization
Value ..> RuleValueList: dependency
Value ..> UnexpectedTokenException: dependency
ValueList ..> OutputFormat: dependency
Value <|-- ValueList: inheritance

CSSList ..> CSSList: dependency
CSSList ..> Comment: dependency
CSSList ..> RuleSet: dependency
CSSNamespace ..> Comment: dependency
Charset ..> Comment: dependency
Import ..> Comment: dependency
OutputFormat ..> OutputFormat: dependency
Rule ..> Comment: dependency
RuleSet ..> Comment: dependency
ValueList ..> Value: dependency
%% end of the generated part
```

## API and deprecation policy
Expand Down
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@
],
"fix:php:fixer": "\"./.phive/php-cs-fixer\" --config=config/php-cs-fixer.php fix bin src tests",
"fix:php:rector": "rector --config=config/rector.php",
"generate:class-diagram": [
"composer require --dev tasuku43/mermaid-class-diagram:0.5.0",
"mermaid-class-diagram generate --path src > class-diagram.md",
"perl -i -0pe 's/( %% start of the generated part).*( %% end of the generated part)/\\1\\nCLASS_DIAGRAM\\n\\2/s' README.md",
"sed -i -n '/CLASS_DIAGRAM/!{p;d;}; r class-diagram.md' README.md",
"sed -i -E 's/(classDiagram)/\\1\\n direction LR\\n/' README.md",
"rm class-diagram.md",
"composer remove --dev tasuku43/mermaid-class-diagram"
],
"phpstan:baseline": "phpstan --configuration=config/phpstan.neon --generate-baseline=config/phpstan-baseline.neon --allow-empty-baseline"
},
"scripts-descriptions": {
Expand All @@ -121,6 +130,7 @@
"fix:php": "Autofixes all autofixable issues in the PHP code.",
"fix:php:fixer": "Fixes autofixable issues found by PHP CS Fixer.",
"fix:php:rector": "Fixes autofixable issues found by Rector.",
"generate:class-diagram": "Updates the class diagram in the README.md file.",
"phpstan:baseline": "Updates the PHPStan baseline file to match the code."
}
}