From 9c75cb4537ce042cba0ae44fac9dcdd87b8c81d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=D0=98U=D0=AFd=20da=20silva?= Date: Tue, 21 May 2019 12:05:52 +0200 Subject: [PATCH] :note: PhpDoc generation for the public API (#63) - generate phpdoc to a dokuwiki compatible format - add/update the phpdoc of a selection of class methods --- .doc/README.md | 52 + .doc/bin/build-doc-extensions | 7 + .doc/bin/build-doc-object-manipulation | 8 + .doc/phpdoc-extensions.dist.xml | 20 + .doc/phpdoc-objects-manipulation.dist.xml | 58 + .doc/phpdoc-templates/.placeholder | 0 .../combodo-wiki/class.txt.twig | 136 + .../combodo-wiki/elements/constant.txt.twig | 31 + .../combodo-wiki/elements/method.txt.twig | 95 + .../combodo-wiki/elements/property.txt.twig | 49 + .../combodo-wiki/file.source.txt.twig | 1 + .../combodo-wiki/file.txt.twig | 122 + .../combodo-wiki/graphs/class.html.twig | 42 + .../combodo-wiki/htaccess.dist | 5 + .../includes/code-examples.txt.twig | 34 + .../includes/inherited-from.txt.twig | 12 + .../namespace-structure-toc.html.twig | 26 + .../combodo-wiki/includes/see-also.txt.twig | 26 + .../includes/tag-synthesys.txt.twig | 56 + .../includes/tags-with-description.txt.twig | 20 + .../combodo-wiki/includes/tags.txt.twig | 22 + .../combodo-wiki/includes/used-by.txt.twig | 24 + .../combodo-wiki/includes/uses.txt.twig | 24 + .../combodo-wiki/includes/wrap-tags.txt.twig | 11 + .../combodo-wiki/interface.txt.twig | 121 + .../combodo-wiki/layout.txt.twig | 5 + .../combodo-wiki/namespace.txt.twig | 51 + .../combodo-wiki/reports/deprecated.html.twig | 49 + .../combodo-wiki/template.xml | 27 + .gitignore | 3 +- application/applicationextension.inc.php | 11 +- composer.lock | 3054 +++++++++++++++++ CONTRIBUTING.md => contributing.md | 0 core/cmdbobject.class.inc.php | 2 + core/dbobject.class.php | 1441 ++++++-- core/dbobjectsearch.class.php | 37 +- core/dbobjectset.class.php | 116 +- core/dbsearch.class.php | 565 ++- core/dbunionsearch.class.php | 22 +- core/metamodel.class.php | 45 +- Jenkinsfile => jenkinsfile | 0 phpdoc.dist.xml | 13 - readme.md | 140 + 43 files changed, 6228 insertions(+), 355 deletions(-) create mode 100644 .doc/README.md create mode 100755 .doc/bin/build-doc-extensions create mode 100755 .doc/bin/build-doc-object-manipulation create mode 100755 .doc/phpdoc-extensions.dist.xml create mode 100755 .doc/phpdoc-objects-manipulation.dist.xml create mode 100644 .doc/phpdoc-templates/.placeholder create mode 100644 .doc/phpdoc-templates/combodo-wiki/class.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/elements/constant.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/elements/method.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/elements/property.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/file.source.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/file.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/graphs/class.html.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/htaccess.dist create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/code-examples.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/inherited-from.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/namespace-structure-toc.html.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/see-also.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/tag-synthesys.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/tags-with-description.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/tags.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/used-by.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/uses.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/includes/wrap-tags.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/interface.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/layout.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/namespace.txt.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/reports/deprecated.html.twig create mode 100644 .doc/phpdoc-templates/combodo-wiki/template.xml create mode 100644 composer.lock rename CONTRIBUTING.md => contributing.md (100%) rename Jenkinsfile => jenkinsfile (100%) delete mode 100644 phpdoc.dist.xml create mode 100644 readme.md diff --git a/.doc/README.md b/.doc/README.md new file mode 100644 index 000000000..2bc851cd7 --- /dev/null +++ b/.doc/README.md @@ -0,0 +1,52 @@ +# phpdoc dokuwiki template +This directory contains a template rendering iTop phpdoc as wiki pages. + + + +## special instructions + +some tags where added : + * `@api-advanced`: it means that a method is an `@api` but mark it also as "complex" to use + * `@overwritable-hook`: used to mark a method as "designed to be extended" + * `@extension-hook`: not used for now + * `@phpdoc-tunning-exclude-inherited`: tunning tag that inform this template to ignere inherited methods in the rendrering. + +some behaviours where added : + * only public `@api` and `@api-advanced` are showed + * class properties are hidden (subject to change, but will require to white list them using `@api` tag) + +known limitations: + * inline tag do not work properly + * links are hardcoded instead of using phpdoc routes (adding our own routes was too complex) + * `@see` tags must be very specific: + * always prefix class members with `Class::` (ie: `DBObject::Get()`) + * for methods always suffix them with `()`, + * for variables, always prefix them with `$`. + * do not use inline @see + * as spaces are used to mark code, the templates have very few indentation, thus they are awful to read (sorry) + * `@example` + * the sentence in the first line (next to the tag) is the title, it must be enclose by double quotes + * the following lines are the sample code. + * 💔 since we simply hack the official tag, this syntax must be respected carefully 💔 + + + +## dokuwiki requirements + * the templates uses the [wrap plugin](https://www.dokuwiki.org/plugin:wrap). + * the generated files have to be placed under an arbitrary directory of `[/path/to/dokuwiki]/data/pages`. + * the html as to be activated [config:htmlok](https://www.dokuwiki.org/config:htmlok) + * the generated files have to be in lowercase + +## installation +``` +composer require phpdocumentor/phpdocumentor:~2 --dev +``` + +## bin +`.doc/bin/build-doc-object-manipulation` and `.doc/bin/build-doc-extensions` contains examples of doc. generation, beware: they have to be called from iTop root directory: +```shell +cd /path/to/itop/ +./.doc/bin/build-doc-object-manipulation +``` + +the resulting documentation is written into `data/phpdocumentor/output` \ No newline at end of file diff --git a/.doc/bin/build-doc-extensions b/.doc/bin/build-doc-extensions new file mode 100755 index 000000000..77be02873 --- /dev/null +++ b/.doc/bin/build-doc-extensions @@ -0,0 +1,7 @@ +#!/bin/sh -x + +rm -rf /tmp/phpdoc-twig-cache/ && rm -rf data/phpdocumentor/output/extensions/ && rm -rf data/phpdocumentor/temp/extensions/ && vendor/bin/phpdoc -c .doc/phpdoc-extensions.dist.xml -vvv + +# now wee need to lowercase every generated file because dokuwiki can't handle uppercase +cd data/phpdocumentor/output/extensions/ +for i in $( ls | grep [A-Z] ); do mv -i $i `echo $i | tr 'A-Z' 'a-z'`; done \ No newline at end of file diff --git a/.doc/bin/build-doc-object-manipulation b/.doc/bin/build-doc-object-manipulation new file mode 100755 index 000000000..ca959a26e --- /dev/null +++ b/.doc/bin/build-doc-object-manipulation @@ -0,0 +1,8 @@ +#!/bin/sh -x + +rm -rf /tmp/phpdoc-twig-cache/ && rm -rf data/phpdocumentor/output/objects-manipulation/ && rm -rf data/phpdocumentor/temp/objects-manipulation/ && vendor/bin/phpdoc -c .doc/phpdoc-objects-manipulation.dist.xml -vvv + + +# now wee need to lowercase every generated file because dokuwiki can't handle uppercase +cd data/phpdocumentor/output/objects-manipulation/ +for i in $( ls | grep [A-Z] ); do mv -i $i `echo $i | tr 'A-Z' 'a-z'`; done \ No newline at end of file diff --git a/.doc/phpdoc-extensions.dist.xml b/.doc/phpdoc-extensions.dist.xml new file mode 100755 index 000000000..826cd61f2 --- /dev/null +++ b/.doc/phpdoc-extensions.dist.xml @@ -0,0 +1,20 @@ + + + <![CDATA[iTop extensions]]> + + + ../data/phpdocumentor/temp/extensions + + + + ../data/phpdocumentor/output/extensions + + + +