Skip to content

Commit 89e8a63

Browse files
authored
docs/publish-readme (#57)
* Remove export-ignore from README.md in .gitattributes. * Add `zero-to-prod/package-helper` dependency and binary script configuration. * Add documentation publishing guide and automatic publishing script instructions to README.md * Add `zero-to-prod-data-model` script for publishing README to documentation directory. * Update `zero-to-prod-data-model` script to adjust target path for data-model directory.
1 parent 4712695 commit 89e8a63

File tree

4 files changed

+75
-4
lines changed

4 files changed

+75
-4
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
/LICENSE.md export-ignore
1212
/LOCAL_DEVELOPMENT.md export-ignore
1313
/phpunit.xml export-ignore
14-
/README.md export-ignore
1514
/SECURITY.md export-ignore
1615
/test.sh export-ignore
1716
/dock export-ignore

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
- [Introduction](#introduction)
1818
- [Why Use DataModel?](#why-use-datamodel)
1919
- [Installation](#installation)
20-
- [Additional Packages](#additional-packages)
20+
- [Documentation Publishing](#documentation-publishing)
21+
- [Automatic Documentation Publishing](#automatic-documentation-publishing)
22+
- [Additional Packages](#additional-packages)
2123
- [Features](#features)
2224
- [Type-Safe](#recursive-hydration)
2325
- [Recursive Instantiation](#recursive-hydration)
@@ -88,6 +90,39 @@ You can install the package via Composer:
8890
composer require zero-to-prod/data-model
8991
```
9092

93+
## Documentation Publishing
94+
95+
You can publish this README to your local documentation directory.
96+
97+
This can be useful for providing documentation for AI agents.
98+
99+
This can be done using the included script:
100+
101+
```bash
102+
# Publish to default location (./docs/zero-to-prod/data-model)
103+
vendor/bin/zero-to-prod-data-model
104+
105+
# Publish to custom directory
106+
vendor/bin/zero-to-prod-data-model /path/to/your/docs
107+
```
108+
109+
#### Automatic Documentation Publishing
110+
111+
You can automatically publish documentation by adding the following to your `composer.json`:
112+
113+
```json
114+
{
115+
"scripts": {
116+
"post-install-cmd": [
117+
"zero-to-prod-data-model"
118+
],
119+
"post-update-cmd": [
120+
"zero-to-prod-data-model"
121+
]
122+
}
123+
}
124+
```
125+
91126
### Additional Packages
92127

93128
- [DataModelHelper](https://github.com/zero-to-prod/data-model-helper): Helpers for a `DataModel`.

bin/zero-to-prod-data-model

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/**
5+
* Zero-to-Prod Factory Documentation Publisher
6+
*
7+
* Publishes the README.md file to the user's documentation directory.
8+
*/
9+
10+
require getcwd().'/vendor/autoload.php';
11+
12+
use Zerotoprod\PackageHelper\PackageHelper;
13+
14+
$target_path = getcwd().'/docs/zero-to-prod/data-model/';
15+
if (isset($argv[1])) {
16+
$target_path = rtrim($argv[1], '/').'/';
17+
}
18+
19+
$source_file = __DIR__.'/../README.md';
20+
21+
if (!file_exists($source_file)) {
22+
fwrite(STDERR, "Error: Not found $source_file\n");
23+
exit(1);
24+
}
25+
26+
try {
27+
PackageHelper::copy($source_file, $target_path);
28+
exit(0);
29+
} catch (RuntimeException $e) {
30+
fwrite(STDERR, "Error: ".$e->getMessage()."\n");
31+
exit(1);
32+
}
33+

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
}
4040
],
4141
"require": {
42-
"php": ">=8.1.0"
42+
"php": ">=8.1.0",
43+
"zero-to-prod/package-helper": "^1.1.3"
4344
},
4445
"require-dev": {
4546
"phpunit/phpunit": "^10.0"
@@ -61,5 +62,8 @@
6162
"files": [
6263
"./tests/functions.php"
6364
]
64-
}
65+
},
66+
"bin": [
67+
"bin/zero-to-prod-data-model"
68+
]
6569
}

0 commit comments

Comments
 (0)