Skip to content

Commit 2e0d45d

Browse files
committed
[FEATURE] Add script for generating the class diagram
1 parent 348b395 commit 2e0d45d

File tree

3 files changed

+88
-21
lines changed

3 files changed

+88
-21
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/.php-cs-fixer.cache
33
/.php_cs.cache
44
/.phpunit.result.cache
5+
/class-diagram.md
56
/composer.lock
67
/coverage.xml
78
/phpstan.neon

README.md

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ class Sabberworm\CSS\CSSList\Document#4 (2) {
619619
## Class diagram
620620

621621
```mermaid
622+
%% start of the generated part
622623
classDiagram
623624
direction LR
624625
@@ -730,76 +731,131 @@ classDiagram
730731
CSSListItem <|-- AtRule: inheritance
731732
AtRule <|.. AtRuleBlockList: realization
732733
CSSBlockList <|-- AtRuleBlockList: inheritance
734+
AtRuleBlockList ..> OutputFormat: dependency
733735
AtRule <|.. AtRuleSet: realization
736+
AtRuleSet ..> OutputFormat: dependency
734737
RuleSet <|-- AtRuleSet: inheritance
735738
CSSList <|-- CSSBlockList: inheritance
736739
Renderable <|-- CSSElement: inheritance
740+
CSSFunction ..> OutputFormat: dependency
741+
CSSFunction ..> ParserState: dependency
737742
ValueList <|-- CSSFunction: inheritance
743+
CSSList ..> AtRuleBlockList: dependency
744+
CSSList ..> AtRuleSet: dependency
738745
CSSElement <|.. CSSList: realization
739746
CSSListItem <|.. CSSList: realization
747+
CSSList ..> CSSNamespace: dependency
740748
CSSList ..> Charset: dependency
741749
CSSList ..> Import: dependency
750+
CSSList ..> KeyFrame: dependency
751+
CSSList ..> OutputFormat: dependency
752+
CSSList ..> ParserState: dependency
742753
Positionable <|.. CSSList: realization
754+
CSSList ..> Selector: dependency
755+
CSSList ..> SourceException: dependency
756+
CSSList ..> UnexpectedTokenException: dependency
743757
Commentable <|-- CSSListItem: inheritance
744758
Renderable <|-- CSSListItem: inheritance
745759
AtRule <|.. CSSNamespace: realization
760+
CSSNamespace ..> OutputFormat: dependency
746761
Positionable <|.. CSSNamespace: realization
762+
CSSString ..> OutputFormat: dependency
763+
CSSString ..> ParserState: dependency
747764
PrimitiveValue <|-- CSSString: inheritance
765+
CSSString ..> SourceException: dependency
748766
CSSFunction <|-- CalcFunction: inheritance
767+
CalcFunction ..> CalcRuleValueList: dependency
768+
CalcFunction ..> ParserState: dependency
769+
CalcFunction ..> RuleValueList: dependency
770+
CalcFunction ..> UnexpectedTokenException: dependency
771+
CalcRuleValueList ..> OutputFormat: dependency
749772
RuleValueList <|-- CalcRuleValueList: inheritance
750773
AtRule <|.. Charset: realization
751774
Charset ..> CSSString: dependency
775+
Charset ..> OutputFormat: dependency
752776
Positionable <|.. Charset: realization
753777
CSSFunction <|-- Color: inheritance
778+
Color ..> OutputFormat: dependency
779+
Color ..> ParserState: dependency
780+
Color ..> Size: dependency
781+
Color ..> UnexpectedTokenException: dependency
782+
Comment ..> OutputFormat: dependency
754783
Positionable <|.. Comment: realization
755784
Renderable <|.. Comment: realization
785+
DeclarationBlock ..> KeyframeSelector: dependency
786+
DeclarationBlock ..> OutputException: dependency
787+
DeclarationBlock ..> OutputFormat: dependency
788+
DeclarationBlock ..> ParserState: dependency
756789
RuleSet <|-- DeclarationBlock: inheritance
757790
DeclarationBlock ..> Selector: dependency
791+
DeclarationBlock ..> UnexpectedTokenException: dependency
758792
CSSBlockList <|-- Document: inheritance
793+
Document ..> OutputFormat: dependency
794+
Document ..> ParserState: dependency
759795
AtRule <|.. Import: realization
796+
Import ..> OutputFormat: dependency
760797
Positionable <|.. Import: realization
798+
Import ..> URL: dependency
761799
AtRule <|.. KeyFrame: realization
762800
CSSList <|-- KeyFrame: inheritance
801+
KeyFrame ..> OutputFormat: dependency
763802
Selector <|-- KeyframeSelector: inheritance
803+
LineName ..> OutputFormat: dependency
804+
LineName ..> ParserState: dependency
764805
ValueList <|-- LineName: inheritance
765806
SourceException <|-- OutputException: inheritance
766807
OutputFormat ..> OutputFormatter: dependency
808+
OutputFormatter ..> Commentable: dependency
809+
OutputFormatter ..> InvalidArgumentException: dependency
767810
OutputFormatter ..> OutputFormat: dependency
811+
Parser ..> Document: dependency
768812
Parser ..> ParserState: dependency
813+
ParserState ..> Anchor: dependency
814+
ParserState ..> Comment: dependency
769815
ParserState ..> Settings: dependency
816+
ParserState ..> SourceException: dependency
817+
ParserState ..> UnexpectedEOFException: dependency
818+
ParserState ..> UnexpectedTokenException: dependency
770819
Value <|-- PrimitiveValue: inheritance
820+
Renderable ..> OutputFormat: dependency
771821
CSSElement <|.. Rule: realization
772822
Commentable <|.. Rule: realization
773-
774-
Positionable <|.. RuleSet: realization
823+
Rule ..> OutputFormat: dependency
824+
Rule ..> ParserState: dependency
825+
Positionable <|.. Rule: realization
826+
Rule ..> RuleValueList: dependency
827+
RuleContainer ..> Rule: dependency
775828
CSSElement <|.. RuleSet: realization
776829
CSSListItem <|.. RuleSet: realization
830+
RuleSet ..> OutputFormat: dependency
831+
RuleSet ..> ParserState: dependency
832+
Positionable <|.. RuleSet: realization
833+
RuleSet ..> Rule: dependency
777834
RuleContainer <|.. RuleSet: realization
835+
RuleSet ..> UnexpectedValueException: dependency
836+
ValueList <|-- RuleValueList: inheritance
837+
Selector ..> OutputFormat: dependency
778838
Renderable <|.. Selector: realization
779-
Positionable <|.. Rule: realization
780-
UnexpectedTokenException <|-- UnexpectedEOFException: inheritance
839+
Size ..> OutputFormat: dependency
840+
Size ..> ParserState: dependency
841+
PrimitiveValue <|-- Size: inheritance
781842
Exception <|-- SourceException: inheritance
782843
Positionable <|.. SourceException: realization
783-
SourceException <|-- UnexpectedTokenException: inheritance
844+
URL ..> CSSString: dependency
845+
URL ..> OutputFormat: dependency
846+
URL ..> ParserState: dependency
784847
PrimitiveValue <|-- URL: inheritance
785-
Value <|-- ValueList: inheritance
848+
UnexpectedTokenException <|-- UnexpectedEOFException: inheritance
849+
SourceException <|-- UnexpectedTokenException: inheritance
786850
CSSElement <|.. Value: realization
851+
Value ..> CSSFunction: dependency
852+
Value ..> ParserState: dependency
787853
Positionable <|.. Value: realization
788-
PrimitiveValue <|-- Size: inheritance
789-
ValueList <|-- RuleValueList: inheritance
790-
CSSList ..> CSSList: dependency
791-
CSSList ..> Comment: dependency
792-
CSSList ..> RuleSet: dependency
793-
CSSNamespace ..> Comment: dependency
794-
Charset ..> Comment: dependency
795-
Import ..> Comment: dependency
796-
OutputFormat ..> OutputFormat: dependency
797-
Rule ..> Comment: dependency
798-
Rule ..> RuleValueList: dependency
799-
RuleSet ..> Comment: dependency
800-
RuleSet ..> Rule: dependency
801-
URL ..> CSSString: dependency
802-
ValueList ..> Value: dependency
854+
Value ..> RuleValueList: dependency
855+
Value ..> UnexpectedTokenException: dependency
856+
ValueList ..> OutputFormat: dependency
857+
Value <|-- ValueList: inheritance
858+
%% end of the generated part
803859
```
804860

805861
## API and deprecation policy

composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@
101101
],
102102
"fix:php:fixer": "\"./.phive/php-cs-fixer\" --config=config/php-cs-fixer.php fix bin src tests",
103103
"fix:php:rector": "rector --config=config/rector.php",
104+
"generate:class-diagram": [
105+
"composer require --dev tasuku43/mermaid-class-diagram:0.5.0",
106+
"mermaid-class-diagram generate --path src > class-diagram.md",
107+
"perl -i -0pe 's/( %% start of the generated part).*( %% end of the generated part)/\\1\\nCLASS_DIAGRAM\\n\\2/s' README.md",
108+
"sed -i -n '/CLASS_DIAGRAM/!{p;d;}; r class-diagram.md' README.md",
109+
"sed -i -E 's/(classDiagram)/\\1\\n direction LR\\n/' README.md",
110+
"rm class-diagram.md",
111+
"composer remove --dev tasuku43/mermaid-class-diagram"
112+
],
104113
"phpstan:baseline": "phpstan --configuration=config/phpstan.neon --generate-baseline=config/phpstan-baseline.neon --allow-empty-baseline"
105114
},
106115
"scripts-descriptions": {
@@ -121,6 +130,7 @@
121130
"fix:php": "Autofixes all autofixable issues in the PHP code.",
122131
"fix:php:fixer": "Fixes autofixable issues found by PHP CS Fixer.",
123132
"fix:php:rector": "Fixes autofixable issues found by Rector.",
133+
"generate:class-diagram": "Updates the class diagram in the README.md file.",
124134
"phpstan:baseline": "Updates the PHPStan baseline file to match the code."
125135
}
126136
}

0 commit comments

Comments
 (0)