Skip to content

Commit b790dc5

Browse files
authored
Merge pull request #126 from andreaswolf/improve-readme
[TASK] Improve README
2 parents d7abd0a + b72afb7 commit b790dc5

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

README.md

+23-17
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Fractor is a generic tool for changing all kinds of files via defined rules—si
66

77
The main package `a9f/fractor` provides infrastructure for configuring, running and extending Fractor,
88
but no rules for changing any files.
9-
These are provided by packages specific for file types (like `a9f/fractor-xml`)
9+
These are provided by individual packages specific for different file types (like `a9f/fractor-xml`)
1010
or ecosystems (like `a9f/typo3-fractor`).
1111

1212
For different file types, different operation modes are possible.
@@ -23,11 +23,12 @@ there is no advanced support available right now.
2323

2424
Install Fractor via composer by running the following command in your terminal:
2525

26-
```
26+
```bash
2727
composer require a9f/fractor a9f/fractor-xml --dev
2828
```
2929

3030
## Configuration
31+
3132
Create a PHP configuration file (e.g., `fractor.php`) where you define the paths to your files.
3233
At minimum, a configuration file must specify the paths to process:
3334

@@ -43,7 +44,7 @@ return FractorConfiguration::configure()
4344
]);
4445
```
4546

46-
If you want to apply only one specific rule you can do so:
47+
If you want to apply only one specific rule, you can do so:
4748

4849
```php
4950
<?php
@@ -54,12 +55,11 @@ use a9f\FractorComposerJson\AddPackageToRequireDevComposerJsonFractorRule;
5455

5556
return FractorConfiguration::configure()
5657
->withPaths([__DIR__ . '/packages/'])
57-
->withConfiguredRule(AddPackageToRequireDevComposerJsonFractorRule::class, [new PackageAndVersion('vendor1/package3', '^3.0')]
58-
)
58+
->withConfiguredRule(AddPackageToRequireDevComposerJsonFractorRule::class, [new PackageAndVersion('vendor1/package3', '^3.0')])
5959
->withRules([AddRenderTypeToFlexFormFractor::class]);
6060
```
6161

62-
You can even skip some rules or files and folders. Do it the following way:
62+
You can also skip some rules or files and folders. Do it the following way:
6363

6464
```php
6565
<?php
@@ -69,8 +69,8 @@ use a9f\Fractor\Configuration\FractorConfiguration;
6969
return FractorConfiguration::configure()
7070
->withPaths([__DIR__ . '/packages/'])
7171
->withSkip([
72-
__DIR__ . '/packages/my_package/crappy_file.txt',
7372
AddRenderTypeToFlexFormFractor::class,
73+
__DIR__ . '/packages/my_package/crappy_file.txt',
7474
__DIR__ . '/packages/my_package/other_crappy_file.txt' => [
7575
AddRenderTypeToFlexFormFractor::class,
7676
]
@@ -84,20 +84,20 @@ return FractorConfiguration::configure()
8484

8585
Execute Fractor from the command line, passing the path to your configuration file as an argument:
8686

87-
```
88-
./vendor/bin/fractor process -f fractor.php
87+
```bash
88+
vendor/bin/fractor process -f fractor.php
8989
```
9090

9191
Fractor will apply the rules specified in the configuration file to the targeted files.
9292
Review the changes made by Fractor to ensure they meet your expectations.
9393

9494
You would also run fractor in dry mode:
9595

96-
```
97-
./vendor/bin/fractor process -f fractor.php --dry-run
96+
```bash
97+
vendor/bin/fractor process -f fractor.php --dry-run
9898
```
9999

100-
Fractor will output all the potential changes on the console without really execution.
100+
Fractor will output all the potential changes on the console without real execution.
101101

102102
## Customization
103103

@@ -113,26 +113,31 @@ Fractor can be extended with additional transformation rules and support for new
113113
Here's how you can extend Fractor with a custom rule:
114114

115115
#### Creating New Rules
116+
116117
- Create a new rule by subclassing the appropriate rule class for the file type,
117-
e.g. `\a9f\FractorXml\XmlFractor` for XML files.
118+
e.g. `\a9f\FractorXml\XmlFractor` for XML files.
118119
- Each rule should specify the conditions under which it should be applied and the corresponding changes to be made.
119120
- Ideally, new rules also have a test case that validates that they work correctly.
120121

121122
#### Registering New Rules
123+
122124
- Register your custom rules within the Fractor configuration file.
123125

124126
### Supporting New File Types
125127

126128
#### Supporting New File Types
129+
127130
- To support a new file type, you will need to implement an instance of `\a9f\Fractor\Fractor\FileProcessor`.
128-
This processor must take care of decoding a file and then traversing the decoded file structure
129-
(e.g. the DOM tree of an XML file; see `\a9f\FractorXml\XmlFileProcessor` for an example)
131+
This processor must take care of decoding a file and then traversing the decoded file structure
132+
(e.g., the DOM tree of an XML file; see `\a9f\FractorXml\XmlFileProcessor` for an example)
130133

131134
### Testing
135+
132136
- Thoroughly test your extensions to ensure they function as expected and do not introduce unintended side effects.
133137
- Write unit tests for your custom rules and parsers to maintain code quality and stability.
134138

135139
### Documentation
140+
136141
- Document your custom rules and file type extensions to aid other users in understanding and utilizing your contributions.
137142

138143
By extending Fractor in this manner, you can enhance its capabilities and adapt it to handle a wider range of file formats and transformation scenarios.
@@ -144,7 +149,8 @@ we welcome contributions from the community. Here's how you can contribute:
144149

145150
1. Fork the repository.
146151
2. Make your changes.
147-
3. Submit a pull request with a clear description of your changes and why they are needed.
152+
3. Run `composer run-script local:contribute`
153+
4. Submit a pull request with a clear description of your changes and why they are needed.
148154

149155
## Support
150156

@@ -162,7 +168,7 @@ We're grateful for their contributions to the PHP ecosystem.
162168
-----
163169

164170
Thank you for using Fractor to streamline your software update process!
165-
We hope it helps make your development workflow more efficient and enjoyable.
171+
We hope it helps to make your development workflow more efficient and enjoyable.
166172
If you have any feedback or suggestions, we'd love to hear from you.
167173

168174
Happy coding! 🚀

0 commit comments

Comments
 (0)