Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vendor
composer.lock
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
# Doctrine Docs Builder

A package for generating Doctrine repo docs in a unified way. Its purpose is to abstract the underlying method away from
the generating command. It assumes the input directory is in `docs/en` at the root of the repo (for now).
the generating command. It assumes:

- it's run from the project root, and
- the docs reside in `docs/en/`.

It uses [phpdocumentor](https://github.com/phpDocumentor/guides) tooling for parsing the RST files.

This project is considered an internal tool and therefore, you shouldn't use this project in your application. This
repository doesn't provide any support, and doesn't guarantee backward compatibility. Any or the entire project can
change, or even disappear, at any moment without prior notice.

## Usage:

```shell
composer require --dev doctrine/docs-builder
./vendor/bin/build-docs.sh [<output>]
composer require --dev doctrine/docs-builder -d docs
./docs/vendor/bin/build-docs.sh [<output>]
```

The output directory defaults to `output` at the root of your project.
The output directory defaults to `docs/output`.

Optionally, declare a script in your root `composer.json` for convenience:

```
"scripts": {
"docs": "./vendor/bin/build-docs.sh @additional_args"
"docs": "./docs/vendor/bin/build-docs.sh @additional_args"
}
```

Expand Down
18 changes: 7 additions & 11 deletions bin/build-docs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

usage="$(basename "$0") [-h] [<outputDir>] -- generate the docs to given output dir [default: output]"
usage="$(basename "$0") [-h] [<outputDir>] -- generate docs to given output dir [default: docs/output]"

# shellcheck disable=SC2034
if getopts ":h" option
Expand All @@ -9,23 +9,19 @@ then
exit
fi

rootDir=$PWD

inputDir="docs/en"
docsRoot="$PWD/docs"

outputArg="${1}"
firstChar=$(echo "$1" | cut -c1-1)

if [ "$firstChar" != "/" ] && [ "$firstChar" != "" ]
then
# Output directory should be relative to working directory
outputArg="$rootDir/$outputArg"
# The output path provided is not an absolute path;
# therefore treat the path as relative to the working dir (project root).
outputArg="$docsRoot/$outputArg"
fi

defaultOutputDir="$rootDir/output"
defaultOutputDir="$docsRoot/output"
outputDir="${outputArg:-${defaultOutputDir:-default}}"

baseDir=$(dirname "$(dirname "$0")")
output=$(composer install -d "$baseDir" 2>&1) || print "$output"

"$baseDir/vendor/bin/guides" -vvv --no-progress --fail-on-log "$rootDir/$inputDir" --output="$outputDir"
"$docsRoot/vendor/bin/guides" -vvv --no-progress --fail-on-log "$docsRoot/en" --output="$outputDir"
Loading