Skip to content

Commit 7a935ba

Browse files
committed
Initial code
1 parent 511364e commit 7a935ba

File tree

5 files changed

+146
-2
lines changed

5 files changed

+146
-2
lines changed

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: monthly
8+
labels:
9+
- dependencies

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea/

README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
1-
# generate-phpdocs-with-evert-phpdoc-md-action
2-
GitHub action to generate PHP project documentation with evert/phpdoc-md library
1+
[![License](https://img.shields.io/github/license/impresscms-dev/generate-phpdocs-with-evert-phpdoc-md-action.svg)](LICENSE)
2+
[![GitHub release](https://img.shields.io/github/release/impresscms-dev/generate-phpdocs-with-evert-phpdoc-md-action.svg)](https://github.com/impresscms-dev/generate-php-project-classes-list-file-action/releases)
3+
4+
# Generate PHP docs with evert/phpdoc-md
5+
6+
GitHub action to generate PHP project documentation in [MarkDown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) format. Based on [clean/phpdoc-md](https://github.com/clean/phpdoc-md) library.
7+
8+
## Usage
9+
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):
11+
```yaml
12+
name: Generate documentation
13+
14+
on:
15+
push:
16+
17+
jobs:
18+
get_php_classes_list:
19+
runs-on: ubuntu-latest
20+
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...
37+
uses: impresscms-dev/[email protected]
38+
with:
39+
output_path: ./docs/
40+
ignored_files: |
41+
test/
42+
extras/
43+
44+
- uses: actions/upload-artifact@v3
45+
with:
46+
name: my-artifact
47+
path: ./docs/
48+
```
49+
50+
## Arguments
51+
52+
This action supports such arguments (used in `with` keyword):
53+
| Argument | Required | Default value | Description |
54+
|-------------|----------|----------------------|-----------------------------------|
55+
| ignored_files | No | | Defines files that can be ignored (supports glob rules; each line means one rule) |
56+
| phpdocumentor_version | No | latest | What [PHP Documentator](https://www.phpdoc.org) version to use? (version = docker image tag) |
57+
| output_path | Yes | | Path where to write generated documentation |
58+
59+
## How to contribute?
60+
61+
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://try.github.io).
62+
63+
If you found any bug or have some questions, use [issues tab](https://github.com/impresscms-dev/generate-phpdocs-with-evert-phpdoc-md-action/issues) and write there your questions.

action.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 'Generate PHP docs with evert/phpdoc-md'
2+
description: 'GitHub action to generate PHP project documentation in MarkDown format. Based on evert/phpdoc-md library.'
3+
4+
branding:
5+
icon: book
6+
color: red
7+
8+
inputs:
9+
ignored_files:
10+
description: "Defines files that can be ignored (supports glob rules; each line means one rule)"
11+
required: false
12+
default: ''
13+
phpdocumentor_version:
14+
description: "What PHP Documentator version to use? (version = docker image tag)"
15+
default: latest
16+
required: false
17+
output_path:
18+
description: "Path where to write generated documentation"
19+
required: true
20+
21+
runs:
22+
using: 'composite'
23+
steps:
24+
- name: Setting env variables...
25+
run: |
26+
echo "GENERATOR_TMP_FILES_PATH=${{ runner.temp }}/phpdocs-${{ github.sha }}-${{ github.run_id }}-${{ github.github.run_attempt }}" >> $GITHUB_ENV
27+
shell: bash
28+
29+
- name: Creating tmp folders...
30+
run: |
31+
rm -rf ${{ env.GENERATOR_TMP_FILES_PATH }} || true
32+
mkdir -p ${{ env.GENERATOR_TMP_FILES_PATH }}
33+
shell: bash
34+
35+
- name: Running phpDocumentator...
36+
run: bash ${{ github.action_path }}/bin/phpdoc.sh "${{ inputs.ignored_files }}" "${{ inputs.phpdocumentor_version }}"
37+
shell: bash
38+
39+
- name: Installing evert/phpdoc-md...
40+
run: composer global require 'evert/phpdoc-md=~0.2.0'
41+
shell: bash
42+
43+
- name: Generating documentation...
44+
run: composer global exec phpdocmd ${{ env.GENERATOR_TMP_FILES_PATH }}/structure.xml {{ inputs.output_path }}
45+
shell: bash
46+
47+
- name: Uninstalling evert/phpdoc-md...
48+
run: composer global remove evert/phpdoc-md
49+
shell: bash
50+
51+
- name: Deleting tmp data...
52+
run: |
53+
rm -rf ${{ env.GENERATOR_TMP_FILES_PATH }} || true
54+
shell: bash

bin/phpdoc.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
IGNORED_FILES=$1
4+
PHPDOC_TAG=$2
5+
6+
GENERATOR_DOCKER_APP_ARGS="--target=/result --directory=/data --cache-folder=/tmp -v --template=xml --ansi --no-interaction"
7+
if [ "$IGNORED_FILES" != "" ]; then
8+
while read -r line
9+
do
10+
GENERATOR_DOCKER_APP_ARGS="$GENERATOR_DOCKER_APP_ARGS --ignore=\"$line\""
11+
done <<< "$IGNORED_FILES"
12+
fi;
13+
14+
docker run \
15+
--rm \
16+
-v ${PWD}:/data \
17+
-v ${GENERATOR_TMP_FILES_PATH}:/result \
18+
phpdoc/phpdoc:$PHPDOC_TAG \
19+
$GENERATOR_DOCKER_APP_ARGS

0 commit comments

Comments
 (0)