Image that supports building documentation from MarkDown within phpDocumentor ...
2.9K
This repo holds the Dockerfile to support phpDocumentor and translate md (MarkDown) files into rst (reStructuredText) files.
| variable name | default | description |
|---|---|---|
FROM_DIR | /data | directory where the script reads sources from |
TO_DIR | /data | directory where the script writes transformed data to |
DEBUG | FALSE | should log messages be printed? |
TOCED_INDEX | TRUE | should index files (with table of content) be created if they do not exist and if they exist should a TOC be inserted? |
TOC_ATTRS | {"maxdepth":"3","hidden":""} | JSON representation of dictionary with attributes for toctree inserted into index files. Special attributes:
.named one overrides .leveled ones. .named and .leveled have their root (level 0) in TO_DIR. |
Given an example data structure like that:
./md
├── amet.md
├── dolor
│ ├── index.md
│ └── sadipscing.md
├── lorem
│ ├── index.md
│ └── ipsum
│ └── consetetur.md
└── sit
└── elitr.md
mkdir -p md/lorem/ipsum \
md/dolor \
md/sit
touch md/amet.md \
md/lorem/index.md \
md/lorem/ipsum/consetetur.md \
md/dolor/sadipscing.md \
md/sit/elitr.md
cat <<EOF > md/dolor/index.md
# Demo index
This index file is a first demonstration file.
EOF
cat <<EOF > md/lorem/index.md
# Demo index
This index file is a second demonstration file.
EOF
And running the docker image like that:
read -r -d '' TOCJSON <<- EOV
{
".named": {
"dolor": {
".prepend": ""
},
"lorem": {
"maxdepth": "1"
}
},
".leveled": {
"0": {
"caption": "Table of contents",
"maxdepth": "3",
"hidden": ""
}
},
"maxdepth": "3",
"hidden": ""
}
EOV
docker run --rm -t \
-v $(pwd)/md:/dataMd -e FROM_DIR="/dataMd" \
-v $(pwd)/rst:/dataRst -e TO_DIR="/dataRst" \
-e TOC_ATTRS="${TOCJSON}" \
macwinnie/md2rst:latest
Will result in this file structure:
./rst
├── amet.rst
├── index.rst
├── dolor
│ ├── index.rst
│ └── sadipscing.rst
├── lorem
│ ├── index.rst
│ └── ipsum
│ ├── consetetur.rst
│ └── index.rst
└── sit
├── elitr.rst
└── index.rst
.. toctree::
:caption: Table of contents
:maxdepth: 3
:hidden:
amet
dolor/index
lorem/index
sit/index
.. toctree::
sadipscing
Demo index
==========
This index file is a first demonstration file.
Demo index
==========
This index file is a second demonstration file.
.. toctree::
:maxdepth: 1
ipsum/index
.. toctree::
:maxdepth: 3
:hidden:
consetetur
.. toctree::
:maxdepth: 3
:hidden:
elitr
If you want to work with the directory levels in a range, you could use e.g. 1.. to define attributes for all levels greater or equal than 1 or 2..3 to define attributes to only be used at 2nd and 3rd levels.
Content type
Image
Digest
sha256:ef918cf09…
Size
403.4 MB
Last updated
3 days ago
docker pull macwinnie/md2rst