From 39b9ca2397be6bd33b261e9c6df9233cde95a36e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Mar 2019 15:45:50 +0100 Subject: [PATCH] Work on documentation generation by modulebuilder --- htdocs/core/class/utils.class.php | 31 ++++++++--- htdocs/langs/en_US/modulebuilder.lang | 2 +- htdocs/modulebuilder/index.php | 18 +++++-- .../template/doc/Documentation.asciidoc | 54 +++++++++++++++++++ ...=> Documentation_full_en.example.asciidoc} | 16 +++++- .../template/doc/Specifications.asciidoc | 29 ---------- 6 files changed, 108 insertions(+), 42 deletions(-) create mode 100644 htdocs/modulebuilder/template/doc/Documentation.asciidoc rename htdocs/modulebuilder/template/doc/{Specifications_full_en.example.asciidoc => Documentation_full_en.example.asciidoc} (88%) delete mode 100644 htdocs/modulebuilder/template/doc/Specifications.asciidoc diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index d3f8e55832a..445bc908847 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -572,7 +572,7 @@ class Utils */ public function generateDoc($module) { - global $conf, $langs; + global $conf, $langs, $user; global $dirins; $error = 0; @@ -666,23 +666,42 @@ class Utils $i++; } - fwrite($fhandle, "\n\n\n== DATA SPECIFICATIONS...\n\n"); + /*fwrite($fhandle, "\n\n\n== DATA SPECIFICATIONS...\n\n"); // TODO fwrite($fhandle, "TODO..."); - fwrite($fhandle, "\n\n\n== CHANGELOG...\n\n"); // TODO fwrite($fhandle, "TODO..."); - - + */ fclose($fhandle); + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '__MYCOMPANY_NAME__'=>$mysoc->name, + '__KEYWORDS__'=>$modulename, + '__USER_FULLNAME__'=>$user->getFullName($langs), + '__USER_EMAIL__'=>$user->email, + '__YYYY-MM-DD__'=>dol_print_date($now, 'dayrfc'), + '---Put here your own copyright and developer email---'=>dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':''), + '__DATA_SPECIFICATION__'=>'Not yet available' + ); + + dolReplaceInFile($spec['fullname'], $arrayreplacement); } - // Copy some files into temp directory + // Copy some files into temp directory, so instruction include::ChangeLog.md[] will works inside the asciidoc file. dol_copy($dirofmodule.'/README.md', $dirofmoduletmp.'/README.md', 0, 1); dol_copy($dirofmodule.'/ChangeLog.md', $dirofmoduletmp.'/ChangeLog.md', 0, 1); diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index a43234e82db..8f9f62e1018 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -45,7 +45,7 @@ SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed. FileNotYetGenerated=File not yet generated RegenerateClassAndSql=Erase and regenerate class and sql files RegenerateMissingFiles=Generate missing files -SpecificationFile=File with business rules +SpecificationFile=File with template documentation LanguageFile=File for language ConfirmDeleteProperty=Are you sure you want to delete the property %s? This will change code in PHP class but also remove column from table definition of object. NotNull=Not NULL diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 414ba60679e..2e66cbed3d1 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -304,7 +304,12 @@ if ($dirins && $action == 'initcli' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '__MYCOMPANY_NAME__'=>$mysoc->name, + '__KEYWORDS__'=>$modulename, + '__USER_FULLNAME__'=>$user->getFullName($langs), + '__USER_EMAIL__'=>$user->email, + '__YYYY-MM-DD__'=>dol_print_date($now, 'dayrfc'), + '---Put here your own copyright and developer email---'=>dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') ); dolReplaceInFile($destfile, $arrayreplacement); @@ -314,8 +319,8 @@ if ($dirins && $action == 'initdoc' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/doc'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; - $srcfile = $srcdir.'/doc/Specifications.asciidoc'; - $destfile = $dirins.'/'.strtolower($module).'/doc/Specifications.asciidoc'; + $srcfile = $srcdir.'/doc/Documentation.asciidoc'; + $destfile = $dirins.'/'.strtolower($module).'/doc/Documentation.asciidoc'; //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); @@ -333,7 +338,12 @@ if ($dirins && $action == 'initdoc' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '__MYCOMPANY_NAME__'=>$mysoc->name, + '__KEYWORDS__'=>$modulename, + '__USER_FULLNAME__'=>$user->getFullName($langs), + '__USER_EMAIL__'=>$user->email, + '__YYYY-MM-DD__'=>dol_print_date($now, 'dayrfc'), + '---Put here your own copyright and developer email---'=>dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') ); dolReplaceInFile($destfile, $arrayreplacement); diff --git a/htdocs/modulebuilder/template/doc/Documentation.asciidoc b/htdocs/modulebuilder/template/doc/Documentation.asciidoc new file mode 100644 index 00000000000..b9fb684e312 --- /dev/null +++ b/htdocs/modulebuilder/template/doc/Documentation.asciidoc @@ -0,0 +1,54 @@ += MYMODULE = +:subtitle: MYMODULE DOCUMENTATION +:source-highlighter: rouge +:companyname: __MYCOMPANY_NAME__ +:corpname: __MYCOMPANY_NAME__ +:orgname: __MYCOMPANY_NAME__ +:creator: __USER_FULLNAME__ +:title: Documentation of module MyModule +:subject: This document is the document of module MyModule. +:keywords: __KEYWORDS__ +// Date du document : +:docdate: __YYYY-MM-DD__ +:toc: manual +:toc-placement: preamble + + +== TOPIC OF DOCUMENT + +This document is the document of module MyModule + + +*Log of versions of document* + +[options="header",format="csv"] +|=== +Author, Date, Version +--- __USER_FULLNAME__ __USER_EMAIL__ ---, __YYYY-MM-DD__, Version 1.0 +|=== + + +[NOTE] +============== +This document was generated using Dolibarr ERP CRM process +============== + + +:toc: manual +:toc-placement: preamble + +<<< + +== INTRODUCTION + +include::README.md[] + + +== DATA SPECIFICATIONS + +__DATA_SPECIFICATION__ + + +== CHANGELOG + +include::ChangeLog.md[] diff --git a/htdocs/modulebuilder/template/doc/Specifications_full_en.example.asciidoc b/htdocs/modulebuilder/template/doc/Documentation_full_en.example.asciidoc similarity index 88% rename from htdocs/modulebuilder/template/doc/Specifications_full_en.example.asciidoc rename to htdocs/modulebuilder/template/doc/Documentation_full_en.example.asciidoc index 6917d7cdd68..4c744210644 100644 --- a/htdocs/modulebuilder/template/doc/Specifications_full_en.example.asciidoc +++ b/htdocs/modulebuilder/template/doc/Documentation_full_en.example.asciidoc @@ -1,5 +1,17 @@ = MYMODULE = -:subtitle: MYMODULE SPECIFICATIONS +:subtitle: MYMODULE DOCUMENTATION +:source-highlighter: rouge +:companyname: __MYCOMPANY_NAME__ +:corpname: __MYCOMPANY_NAME__ +:orgname: __MYCOMPANY_NAME__ +:creator: __USER_FULLNAME__ +:title: Documentation of module MyModule +:subject: This document is the document of module MyModule. +:keywords: __KEYWORDS__ +// Date du document : +:docdate: __YYYY-MM-DD__ +:toc: manual +:toc-placement: preamble @@ -39,7 +51,7 @@ external documents stored in the *Appendices* directory accompanying this docume [options="header",format="csv"] |=== Author, Date, Version -John Doe, Date YYYY-MM-DD, Version 1.0 +--- __USER_FULLNAME__ __USER_EMAIL__ ---, __YYYY-MM-DD__, Version 1.0 |=== diff --git a/htdocs/modulebuilder/template/doc/Specifications.asciidoc b/htdocs/modulebuilder/template/doc/Specifications.asciidoc deleted file mode 100644 index 232ba7a705f..00000000000 --- a/htdocs/modulebuilder/template/doc/Specifications.asciidoc +++ /dev/null @@ -1,29 +0,0 @@ -= MYMODULE = -:subtitle: MYMODULE SPECIFICATIONS - - - -== TOPIC OF DOCUMENT - -This document describe specifications of module MyModule - - -*Log of versions of document* - -[options="header",format="csv"] -|=== -Author, Date, Version ----Put here your own copyright and developer email---, Date YYYY-MM-DD, Version 1.0 -|=== - - -[NOTE] -============== -This document was generated using Dolibarr ERP CRM process -============== - -<<< - -///include::README.md[] - -///include::ChangeLog.md[]