|
1 | 1 | [](LICENSE) |
2 | | -[](https://github.com/impresscms-dev/generate-php-project-classes-list-file-action/releases) |
| 2 | +[](https://github.com/impresscms-dev/flattern-markdown-folder-structure-action/releases) |
3 | 3 |
|
4 | | -# Flattern MarkDown folder structure |
| 4 | +# Flattern Markdown Folder Structure |
5 | 5 |
|
6 | | -GitHub action to flattern file structure with [MarkDown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) data. |
| 6 | +A GitHub Action that flattens a directory structure containing Markdown files while preserving and updating internal links between documents. |
| 7 | + |
| 8 | +## What This Action Does |
| 9 | + |
| 10 | +This action: |
| 11 | + |
| 12 | +1. Takes a directory containing Markdown files in a nested folder structure |
| 13 | +2. Moves all files to the root of that directory |
| 14 | +3. Renames files to avoid naming conflicts (adding folder path in parentheses when needed) |
| 15 | +4. Updates all internal links between documents to maintain proper references |
| 16 | + |
| 17 | +This is particularly useful for documentation generation workflows where you want a flat structure for publishing or deployment. |
7 | 18 |
|
8 | 19 | ## Usage |
9 | 20 |
|
10 | | -To use this action in your project, create workflow in your project similar to this code (Note: some parts and arguments needs to be altered): |
| 21 | +To use this action in your project, create a workflow in your GitHub repository similar to this example (customize as needed): |
11 | 22 | ```yaml |
12 | | -name: Generate documentation |
| 23 | +name: Generate and Flatten Documentation |
13 | 24 |
|
14 | 25 | on: |
15 | 26 | push: |
| 27 | + branches: [main, master] |
16 | 28 |
|
17 | 29 | jobs: |
18 | | - get_php_classes_list: |
| 30 | + flatten_docs: |
19 | 31 | runs-on: ubuntu-latest |
20 | 32 | steps: |
21 | | - - name: Checkouting project code... |
22 | | - uses: actions/checkout@v2 |
23 | | - |
24 | | - - name: Install PHP |
25 | | - uses: shivammathur/setup-php@master |
26 | | - with: |
27 | | - php-version: 8.1 |
28 | | - extensions: curl, gd, pdo_mysql, json, mbstring, pcre, session |
29 | | - ini-values: post_max_size=256M |
30 | | - coverage: none |
31 | | - tools: composer:v2 |
32 | | - |
33 | | - - name: Install Composer dependencies (with dev) |
34 | | - run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader |
35 | | - |
36 | | - - name: Generating documentation... |
| 33 | + - name: Checkout repository |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + # Generate documentation (example using PHP docs generator) |
| 37 | + - name: Generate documentation |
37 | 38 | uses: impresscms-dev/[email protected] |
38 | 39 | with: |
39 | | - class_root_namespace: ImpressCMS\ |
40 | | - included_classes: ImpressCMS\** |
| 40 | + class_root_namespace: YourNamespace\ |
| 41 | + included_classes: YourNamespace\** |
41 | 42 | output_path: ./docs/ |
42 | | - |
43 | | - - name: Flattering documentation... |
44 | | - uses: impresscms-dev/[email protected] |
| 43 | + |
| 44 | + # Flatten the documentation structure |
| 45 | + - name: Flatten documentation structure |
| 46 | + uses: impresscms-dev/flattern-markdown-folder-structure-action@v2 |
45 | 47 | with: |
46 | 48 | path: ./docs/ |
47 | | - |
48 | | - - uses: actions/upload-artifact@v3 |
| 49 | + |
| 50 | + # Optional: Upload the flattened docs as an artifact |
| 51 | + - name: Upload documentation |
| 52 | + uses: actions/upload-artifact@v4 |
49 | 53 | with: |
50 | | - name: my-artifact |
| 54 | + name: documentation |
51 | 55 | path: ./docs/ |
52 | 56 | ``` |
53 | 57 |
|
54 | 58 | ## Arguments |
55 | 59 |
|
56 | | -This action supports such arguments (used in `with` keyword): |
57 | | -| Argument | Required | Default value | Description | |
58 | | -|-------------|----------|----------------------|-----------------------------------| |
59 | | -| path | Yes | | Folder to flattern | |
| 60 | +This action supports the following arguments (used with the `with` keyword): |
| 61 | + |
| 62 | +| Argument | Required | Default value | Description | |
| 63 | +|----------|----------|---------------|-------------| |
| 64 | +| path | Yes | - | Path to the folder containing Markdown files that should be flattened | |
| 65 | + |
| 66 | +## How File Renaming Works |
| 67 | + |
| 68 | +When flattening the directory structure, the action: |
| 69 | + |
| 70 | +1. Moves all files to the root directory |
| 71 | +2. If filename conflicts occur, the action renames files by adding the original folder path in parentheses |
| 72 | + - Example: `subfolder/document.md` becomes `document (subfolder).md` |
| 73 | +3. Updates all internal Markdown links to maintain proper references between documents |
| 74 | + |
| 75 | +## Examples |
| 76 | + |
| 77 | +### Before Flattening |
| 78 | +``` |
| 79 | +docs/ |
| 80 | +├── README.md |
| 81 | +├── getting-started.md |
| 82 | +├── api/ |
| 83 | +│ ├── endpoints.md |
| 84 | +│ └── authentication.md |
| 85 | +└── guides/ |
| 86 | + ├── installation.md |
| 87 | + └── configuration.md |
| 88 | +``` |
| 89 | +
|
| 90 | +### After Flattening |
| 91 | +``` |
| 92 | +docs/ |
| 93 | +├── README.md |
| 94 | +├── getting-started.md |
| 95 | +├── endpoints (api).md |
| 96 | +├── authentication (api).md |
| 97 | +├── installation (guides).md |
| 98 | +└── configuration (guides).md |
| 99 | +``` |
60 | 100 |
|
61 | | -## How to contribute? |
| 101 | +## How to Contribute |
62 | 102 |
|
63 | | -If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how this works, try [interactive GitHub tutorial](https://skills.github.com). |
| 103 | +If you want to add functionality or fix bugs, you can fork the repository, make your changes, and create a pull request. If you're not sure how this works, check out GitHub's [fork a repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo) and [creating a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) guides. |
64 | 104 |
|
65 | | -If you found any bug or have some questions, use [issues tab](https://github.com/impresscms-dev/flattern-markdown-folder-structure-action/issues) and write there your questions. |
| 105 | +If you find a bug or have questions, please use the [issues tab](https://github.com/impresscms-dev/flattern-markdown-folder-structure-action/issues) to report them. |
0 commit comments