Skip to content

Commit 85e0136

Browse files
committed
[FEATURE] Add script for generating the class diagram
1 parent ab9fa7f commit 85e0136

File tree

3 files changed

+120
-53
lines changed

3 files changed

+120
-53
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: 109 additions & 53 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
737-
738-
RuleSet <|-- DeclarationBlock: inheritance
739-
Renderable <|-- CSSListItem: inheritance
740-
Commentable <|-- CSSListItem: inheritance
741-
Positionable <|.. RuleSet: realization
742-
CSSElement <|.. RuleSet: realization
743-
CSSListItem <|.. RuleSet: realization
744-
RuleContainer <|.. RuleSet: realization
745-
Renderable <|.. Selector: realization
746-
Selector <|-- KeyframeSelector: inheritance
747-
Positionable <|.. Charset: realization
748-
AtRule <|.. Charset: realization
749-
Positionable <|.. Import: realization
750-
AtRule <|.. Import: realization
751-
Positionable <|.. CSSNamespace: realization
752-
AtRule <|.. CSSNamespace: realization
753-
CSSElement <|.. Rule: realization
754-
Positionable <|.. Rule: realization
755-
Commentable <|.. Rule: realization
756-
SourceException <|-- OutputException: inheritance
757-
UnexpectedTokenException <|-- UnexpectedEOFException: inheritance
758-
Exception <|-- SourceException: inheritance
759-
Positionable <|.. SourceException: realization
760-
SourceException <|-- UnexpectedTokenException: inheritance
761-
CSSBlockList <|-- Document: inheritance
740+
CSSFunction ..> OutputFormat: dependency
741+
CSSFunction ..> ParserState: dependency
742+
ValueList <|-- CSSFunction: inheritance
743+
CSSList ..> AtRuleBlockList: dependency
744+
CSSList ..> AtRuleSet: dependency
762745
CSSElement <|.. CSSList: realization
763-
Positionable <|.. CSSList: realization
764746
CSSListItem <|.. CSSList: realization
765-
CSSList <|-- KeyFrame: inheritance
766-
AtRule <|.. KeyFrame: realization
767-
CSSFunction <|-- Color: inheritance
768-
PrimitiveValue <|-- URL: inheritance
769-
RuleValueList <|-- CalcRuleValueList: inheritance
770-
Value <|-- ValueList: inheritance
771-
CSSFunction <|-- CalcFunction: inheritance
772-
ValueList <|-- LineName: inheritance
773-
CSSElement <|.. Value: realization
774-
Positionable <|.. Value: realization
775-
PrimitiveValue <|-- Size: inheritance
776-
PrimitiveValue <|-- CSSString: inheritance
777-
Value <|-- PrimitiveValue: inheritance
778-
ValueList <|-- CSSFunction: inheritance
779-
ValueList <|-- RuleValueList: inheritance
780-
Renderable <|.. Comment: realization
781-
Positionable <|.. Comment: realization
782-
CSSList ..> CSSList: dependency
747+
CSSList ..> CSSNamespace: dependency
783748
CSSList ..> Charset: dependency
784-
CSSList ..> Comment: dependency
785749
CSSList ..> Import: dependency
786-
CSSList ..> RuleSet: dependency
787-
CSSNamespace ..> Comment: dependency
788-
Charset ..> Comment: dependency
750+
CSSList ..> KeyFrame: dependency
751+
CSSList ..> OutputFormat: dependency
752+
CSSList ..> ParserState: dependency
753+
Positionable <|.. CSSList: realization
754+
CSSList ..> Selector: dependency
755+
CSSList ..> SourceException: dependency
756+
CSSList ..> UnexpectedTokenException: dependency
757+
Commentable <|-- CSSListItem: inheritance
758+
Renderable <|-- CSSListItem: inheritance
759+
AtRule <|.. CSSNamespace: realization
760+
CSSNamespace ..> OutputFormat: dependency
761+
Positionable <|.. CSSNamespace: realization
762+
CSSString ..> OutputFormat: dependency
763+
CSSString ..> ParserState: dependency
764+
PrimitiveValue <|-- CSSString: inheritance
765+
CSSString ..> SourceException: dependency
766+
CSSFunction <|-- CalcFunction: inheritance
767+
CalcFunction ..> CalcRuleValueList: dependency
768+
CalcFunction ..> ParserState: dependency
769+
CalcFunction ..> RuleValueList: dependency
770+
CalcFunction ..> UnexpectedTokenException: dependency
771+
CalcRuleValueList ..> OutputFormat: dependency
772+
RuleValueList <|-- CalcRuleValueList: inheritance
773+
AtRule <|.. Charset: realization
789774
Charset ..> CSSString: dependency
775+
Charset ..> OutputFormat: dependency
776+
Positionable <|.. Charset: realization
777+
CSSFunction <|-- Color: inheritance
778+
Color ..> OutputFormat: dependency
779+
Color ..> ParserState: dependency
780+
Color ..> Size: dependency
781+
Color ..> UnexpectedTokenException: dependency
782+
Comment ..> OutputFormat: dependency
783+
Positionable <|.. Comment: realization
784+
Renderable <|.. Comment: realization
785+
DeclarationBlock ..> KeyframeSelector: dependency
786+
DeclarationBlock ..> OutputException: dependency
787+
DeclarationBlock ..> OutputFormat: dependency
788+
DeclarationBlock ..> ParserState: dependency
789+
RuleSet <|-- DeclarationBlock: inheritance
790790
DeclarationBlock ..> Selector: dependency
791-
Import ..> Comment: dependency
792-
OutputFormat ..> OutputFormat: dependency
791+
DeclarationBlock ..> UnexpectedTokenException: dependency
792+
CSSBlockList <|-- Document: inheritance
793+
Document ..> OutputFormat: dependency
794+
Document ..> ParserState: dependency
795+
AtRule <|.. Import: realization
796+
Import ..> OutputFormat: dependency
797+
Positionable <|.. Import: realization
798+
Import ..> URL: dependency
799+
AtRule <|.. KeyFrame: realization
800+
CSSList <|-- KeyFrame: inheritance
801+
KeyFrame ..> OutputFormat: dependency
802+
Selector <|-- KeyframeSelector: inheritance
803+
LineName ..> OutputFormat: dependency
804+
LineName ..> ParserState: dependency
805+
ValueList <|-- LineName: inheritance
806+
SourceException <|-- OutputException: inheritance
793807
OutputFormat ..> OutputFormatter: dependency
808+
OutputFormatter ..> Commentable: dependency
809+
OutputFormatter ..> InvalidArgumentException: dependency
794810
OutputFormatter ..> OutputFormat: dependency
811+
Parser ..> Document: dependency
795812
Parser ..> ParserState: dependency
813+
ParserState ..> Anchor: dependency
814+
ParserState ..> Comment: dependency
796815
ParserState ..> Settings: dependency
797-
Rule ..> Comment: dependency
816+
ParserState ..> SourceException: dependency
817+
ParserState ..> UnexpectedEOFException: dependency
818+
ParserState ..> UnexpectedTokenException: dependency
819+
Value <|-- PrimitiveValue: inheritance
820+
Renderable ..> OutputFormat: dependency
821+
CSSElement <|.. Rule: realization
822+
Commentable <|.. Rule: realization
823+
Rule ..> OutputFormat: dependency
824+
Rule ..> ParserState: dependency
825+
Positionable <|.. Rule: realization
798826
Rule ..> RuleValueList: dependency
799-
RuleSet ..> Comment: dependency
827+
RuleContainer ..> Rule: dependency
828+
CSSElement <|.. RuleSet: realization
829+
CSSListItem <|.. RuleSet: realization
830+
RuleSet ..> OutputFormat: dependency
831+
RuleSet ..> ParserState: dependency
832+
Positionable <|.. RuleSet: realization
800833
RuleSet ..> Rule: dependency
834+
RuleContainer <|.. RuleSet: realization
835+
RuleSet ..> UnexpectedValueException: dependency
836+
ValueList <|-- RuleValueList: inheritance
837+
Selector ..> OutputFormat: dependency
838+
Renderable <|.. Selector: realization
839+
Size ..> OutputFormat: dependency
840+
Size ..> ParserState: dependency
841+
PrimitiveValue <|-- Size: inheritance
842+
Exception <|-- SourceException: inheritance
843+
Positionable <|.. SourceException: realization
801844
URL ..> CSSString: dependency
802-
ValueList ..> Value: dependency
845+
URL ..> OutputFormat: dependency
846+
URL ..> ParserState: dependency
847+
PrimitiveValue <|-- URL: inheritance
848+
UnexpectedTokenException <|-- UnexpectedEOFException: inheritance
849+
SourceException <|-- UnexpectedTokenException: inheritance
850+
CSSElement <|.. Value: realization
851+
Value ..> CSSFunction: dependency
852+
Value ..> ParserState: dependency
853+
Positionable <|.. Value: realization
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)