Skip to content

Commit f3adfab

Browse files
committed
[FEATURE] Add script for generating the class diagram
1 parent 99fcc08 commit f3adfab

File tree

3 files changed

+80
-12
lines changed

3 files changed

+80
-12
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: 69 additions & 12 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
@@ -729,80 +730,136 @@ classDiagram
729730
CSSListItem <|-- AtRule: inheritance
730731
AtRule <|.. AtRuleBlockList: realization
731732
CSSBlockList <|-- AtRuleBlockList: inheritance
733+
AtRuleBlockList ..> OutputFormat: dependency
732734
AtRule <|.. AtRuleSet: realization
735+
AtRuleSet ..> OutputFormat: dependency
733736
RuleSet <|-- AtRuleSet: inheritance
734737
CSSList <|-- CSSBlockList: inheritance
735738
Renderable <|-- CSSElement: inheritance
739+
CSSFunction ..> OutputFormat: dependency
740+
CSSFunction ..> ParserState: dependency
736741
ValueList <|-- CSSFunction: inheritance
742+
CSSList ..> AtRuleBlockList: dependency
743+
CSSList ..> AtRuleSet: dependency
737744
CSSElement <|.. CSSList: realization
738745
CSSListItem <|.. CSSList: realization
746+
CSSList ..> CSSNamespace: dependency
739747
CSSList ..> Charset: dependency
740748
CSSList ..> Import: dependency
749+
CSSList ..> KeyFrame: dependency
750+
CSSList ..> OutputFormat: dependency
751+
CSSList ..> ParserState: dependency
741752
Positionable <|.. CSSList: realization
753+
CSSList ..> Selector: dependency
754+
CSSList ..> SourceException: dependency
755+
CSSList ..> UnexpectedTokenException: dependency
742756
Commentable <|-- CSSListItem: inheritance
743757
Renderable <|-- CSSListItem: inheritance
744758
AtRule <|.. CSSNamespace: realization
759+
CSSNamespace ..> OutputFormat: dependency
745760
Positionable <|.. CSSNamespace: realization
761+
CSSString ..> OutputFormat: dependency
762+
CSSString ..> ParserState: dependency
746763
PrimitiveValue <|-- CSSString: inheritance
764+
CSSString ..> SourceException: dependency
747765
CSSFunction <|-- CalcFunction: inheritance
766+
CalcFunction ..> CalcRuleValueList: dependency
767+
CalcFunction ..> ParserState: dependency
768+
CalcFunction ..> RuleValueList: dependency
769+
CalcFunction ..> UnexpectedTokenException: dependency
770+
CalcRuleValueList ..> OutputFormat: dependency
748771
RuleValueList <|-- CalcRuleValueList: inheritance
749772
AtRule <|.. Charset: realization
750773
Charset ..> CSSString: dependency
774+
Charset ..> OutputFormat: dependency
751775
Positionable <|.. Charset: realization
752776
CSSFunction <|-- Color: inheritance
777+
Color ..> OutputFormat: dependency
778+
Color ..> ParserState: dependency
779+
Color ..> Size: dependency
780+
Color ..> UnexpectedTokenException: dependency
781+
Comment ..> OutputFormat: dependency
753782
Positionable <|.. Comment: realization
754783
Renderable <|.. Comment: realization
755784
CSSElement <|.. DeclarationBlock: realization
756785
CSSListItem <|.. DeclarationBlock: realization
786+
DeclarationBlock ..> KeyframeSelector: dependency
787+
DeclarationBlock ..> OutputException: dependency
788+
DeclarationBlock ..> OutputFormat: dependency
789+
DeclarationBlock ..> ParserState: dependency
757790
Positionable <|.. DeclarationBlock: realization
791+
DeclarationBlock ..> Rule: dependency
758792
RuleContainer <|.. DeclarationBlock: realization
759-
DeclarationBlock ..> RuleSet : dependency
793+
DeclarationBlock ..> RuleSet: dependency
760794
DeclarationBlock ..> Selector: dependency
795+
DeclarationBlock ..> UnexpectedTokenException: dependency
761796
CSSBlockList <|-- Document: inheritance
797+
Document ..> OutputFormat: dependency
798+
Document ..> ParserState: dependency
762799
AtRule <|.. Import: realization
800+
Import ..> OutputFormat: dependency
763801
Positionable <|.. Import: realization
802+
Import ..> URL: dependency
764803
AtRule <|.. KeyFrame: realization
765804
CSSList <|-- KeyFrame: inheritance
805+
KeyFrame ..> OutputFormat: dependency
766806
Selector <|-- KeyframeSelector: inheritance
807+
LineName ..> OutputFormat: dependency
808+
LineName ..> ParserState: dependency
767809
ValueList <|-- LineName: inheritance
768810
SourceException <|-- OutputException: inheritance
769811
OutputFormat ..> OutputFormatter: dependency
812+
OutputFormatter ..> Commentable: dependency
813+
OutputFormatter ..> InvalidArgumentException: dependency
770814
OutputFormatter ..> OutputFormat: dependency
815+
Parser ..> Document: dependency
771816
Parser ..> ParserState: dependency
817+
ParserState ..> Anchor: dependency
818+
ParserState ..> Comment: dependency
772819
ParserState ..> Settings: dependency
820+
ParserState ..> SourceException: dependency
821+
ParserState ..> UnexpectedEOFException: dependency
822+
ParserState ..> UnexpectedTokenException: dependency
773823
Value <|-- PrimitiveValue: inheritance
824+
Renderable ..> OutputFormat: dependency
774825
CSSElement <|.. Rule: realization
775826
Commentable <|.. Rule: realization
827+
Rule ..> OutputFormat: dependency
828+
Rule ..> ParserState: dependency
776829
Positionable <|.. Rule: realization
777830
Rule ..> RuleValueList: dependency
831+
RuleContainer ..> Rule: dependency
778832
CSSElement <|.. RuleSet: realization
779833
CSSListItem <|.. RuleSet: realization
834+
RuleSet ..> OutputFormat: dependency
835+
RuleSet ..> ParserState: dependency
780836
Positionable <|.. RuleSet: realization
781837
RuleSet ..> Rule: dependency
782838
RuleContainer <|.. RuleSet: realization
839+
RuleSet ..> UnexpectedValueException: dependency
783840
ValueList <|-- RuleValueList: inheritance
841+
Selector ..> OutputFormat: dependency
784842
Renderable <|.. Selector: realization
843+
Size ..> OutputFormat: dependency
844+
Size ..> ParserState: dependency
785845
PrimitiveValue <|-- Size: inheritance
786846
Exception <|-- SourceException: inheritance
787847
Positionable <|.. SourceException: realization
788848
URL ..> CSSString: dependency
849+
URL ..> OutputFormat: dependency
850+
URL ..> ParserState: dependency
789851
PrimitiveValue <|-- URL: inheritance
790852
UnexpectedTokenException <|-- UnexpectedEOFException: inheritance
791853
SourceException <|-- UnexpectedTokenException: inheritance
792854
CSSElement <|.. Value: realization
855+
Value ..> CSSFunction: dependency
856+
Value ..> ParserState: dependency
793857
Positionable <|.. Value: realization
858+
Value ..> RuleValueList: dependency
859+
Value ..> UnexpectedTokenException: dependency
860+
ValueList ..> OutputFormat: dependency
794861
Value <|-- ValueList: inheritance
795-
796-
CSSList ..> CSSList: dependency
797-
CSSList ..> Comment: dependency
798-
CSSList ..> RuleSet: dependency
799-
CSSNamespace ..> Comment: dependency
800-
Charset ..> Comment: dependency
801-
Import ..> Comment: dependency
802-
OutputFormat ..> OutputFormat: dependency
803-
Rule ..> Comment: dependency
804-
RuleSet ..> Comment: dependency
805-
ValueList ..> Value: dependency
862+
%% end of the generated part
806863
```
807864

808865
## 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.6.0",
106+
"mermaid-class-diagram generate --path src --exclude-relationships composition > 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)