Skip to content

Commit 017d1b6

Browse files
committed
[FEATURE] Add script for generating the class diagram
1 parent 63b22be commit 017d1b6

File tree

3 files changed

+128
-64
lines changed

3 files changed

+128
-64
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: 117 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -727,82 +727,135 @@ classDiagram
727727
<<abstract>>
728728
}
729729
730-
RuleSet <|-- DeclarationBlock: inheritance
730+
Anchor ..> ParserState: dependency
731+
CSSListItem <|-- AtRule: inheritance
732+
AtRule <|.. AtRuleBlockList: realization
733+
CSSBlockList <|-- AtRuleBlockList: inheritance
734+
AtRuleBlockList ..> OutputFormat: dependency
735+
AtRule <|.. AtRuleSet: realization
736+
AtRuleSet ..> OutputFormat: dependency
737+
RuleSet <|-- AtRuleSet: inheritance
738+
CSSList <|-- CSSBlockList: inheritance
731739
Renderable <|-- CSSElement: inheritance
732-
Renderable <|-- CSSListItem: inheritance
740+
CSSFunction ..> OutputFormat: dependency
741+
CSSFunction ..> ParserState: dependency
742+
ValueList <|-- CSSFunction: inheritance
743+
CSSList ..> AtRuleBlockList: dependency
744+
CSSList ..> AtRuleSet: dependency
745+
CSSElement <|.. CSSList: realization
746+
CSSListItem <|.. CSSList: realization
747+
CSSList ..> CSSNamespace: dependency
748+
CSSList ..> Charset: dependency
749+
CSSList ..> Import: 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
733757
Commentable <|-- CSSListItem: inheritance
734-
Positionable <|.. RuleSet: realization
735-
CSSElement <|.. RuleSet: realization
736-
CSSListItem <|.. RuleSet: realization
737-
RuleContainer <|.. RuleSet: realization
738-
RuleSet <|-- AtRuleSet: inheritance
739-
AtRule <|.. AtRuleSet: realization
740-
Renderable <|.. Selector: realization
741-
Selector <|-- KeyframeSelector: inheritance
742-
CSSListItem <|-- AtRule: inheritance
743-
Positionable <|.. Charset: realization
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
744773
AtRule <|.. Charset: realization
745-
Positionable <|.. Import: realization
774+
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
790+
DeclarationBlock ..> Selector: dependency
791+
DeclarationBlock ..> UnexpectedTokenException: dependency
792+
CSSBlockList <|-- Document: inheritance
793+
Document ..> OutputFormat: dependency
794+
Document ..> ParserState: dependency
746795
AtRule <|.. Import: realization
747-
Positionable <|.. CSSNamespace: realization
748-
AtRule <|.. CSSNamespace: 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
807+
OutputFormat ..> OutputFormatter: dependency
808+
OutputFormatter ..> Commentable: dependency
809+
OutputFormatter ..> InvalidArgumentException: dependency
810+
OutputFormatter ..> OutputFormat: dependency
811+
Parser ..> Document: dependency
812+
Parser ..> ParserState: dependency
813+
ParserState ..> Anchor: dependency
814+
ParserState ..> Comment: dependency
815+
ParserState ..> Settings: dependency
816+
ParserState ..> SourceException: dependency
817+
ParserState ..> UnexpectedEOFException: dependency
818+
ParserState ..> UnexpectedTokenException: dependency
819+
Value <|-- PrimitiveValue: inheritance
820+
Renderable ..> OutputFormat: dependency
749821
CSSElement <|.. Rule: realization
750-
Positionable <|.. Rule: realization
751822
Commentable <|.. Rule: realization
752-
SourceException <|-- OutputException: inheritance
753-
UnexpectedTokenException <|-- UnexpectedEOFException: inheritance
823+
Rule ..> OutputFormat: dependency
824+
Rule ..> ParserState: dependency
825+
Positionable <|.. Rule: realization
826+
Rule ..> RuleValueList: 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
833+
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
754842
Exception <|-- SourceException: inheritance
755843
Positionable <|.. SourceException: realization
756-
SourceException <|-- UnexpectedTokenException: inheritance
757-
CSSList <|-- CSSBlockList: inheritance
758-
CSSBlockList <|-- Document: inheritance
759-
CSSElement <|.. CSSList: realization
760-
Positionable <|.. CSSList: realization
761-
CSSListItem <|.. CSSList: realization
762-
CSSList <|-- KeyFrame: inheritance
763-
AtRule <|.. KeyFrame: realization
764-
CSSBlockList <|-- AtRuleBlockList: inheritance
765-
AtRule <|.. AtRuleBlockList: realization
766-
CSSFunction <|-- Color: inheritance
844+
URL ..> CSSString: dependency
845+
URL ..> OutputFormat: dependency
846+
URL ..> ParserState: dependency
767847
PrimitiveValue <|-- URL: inheritance
768-
RuleValueList <|-- CalcRuleValueList: inheritance
769-
Value <|-- ValueList: inheritance
770-
CSSFunction <|-- CalcFunction: inheritance
771-
ValueList <|-- LineName: inheritance
848+
UnexpectedTokenException <|-- UnexpectedEOFException: inheritance
849+
SourceException <|-- UnexpectedTokenException: inheritance
772850
CSSElement <|.. Value: realization
851+
Value ..> CSSFunction: dependency
852+
Value ..> ParserState: dependency
773853
Positionable <|.. Value: realization
774-
PrimitiveValue <|-- Size: inheritance
775-
PrimitiveValue <|-- CSSString: inheritance
776-
Value <|-- PrimitiveValue: inheritance
777-
ValueList <|-- CSSFunction: inheritance
778-
ValueList <|-- RuleValueList: inheritance
779-
Renderable <|.. Comment: realization
780-
Positionable <|.. Comment: realization
854+
Value ..> RuleValueList: dependency
855+
Value ..> UnexpectedTokenException: dependency
856+
ValueList ..> OutputFormat: dependency
857+
Value <|-- ValueList: inheritance
781858
%% end of the generated part
782-
783-
784-
Anchor ..> ParserState: parserState
785-
CSSList ..> CSSList: contents
786-
CSSList ..> Charset: contents
787-
CSSList ..> Comment: comments
788-
CSSList ..> Import: contents
789-
CSSList ..> RuleSet: contents
790-
CSSNamespace ..> Comment: comments
791-
Charset ..> Comment: comments
792-
Charset ..> CSSString: charset
793-
DeclarationBlock ..> Selector: selectors
794-
Import ..> Comment: comments
795-
OutputFormat ..> OutputFormat: nextLevelFormat
796-
OutputFormat ..> OutputFormatter: outputFormatter
797-
OutputFormatter ..> OutputFormat: outputFormat
798-
Parser ..> ParserState: parserState
799-
ParserState ..> Settings: parserSettings
800-
Rule ..> Comment: comments
801-
Rule ..> RuleValueList: value
802-
RuleSet ..> Comment: comments
803-
RuleSet ..> Rule: rules
804-
URL ..> CSSString: url
805-
ValueList ..> Value: components
806859
```
807860

808861
## 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)