Work on documentation generation by modulebuilder

This commit is contained in:
Laurent Destailleur 2019-03-17 15:45:50 +01:00
parent 7f007f4182
commit 39b9ca2397
6 changed files with 108 additions and 42 deletions

View File

@ -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);

View File

@ -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 <strong>%s</strong>? This will change code in PHP class but also remove column from table definition of object.
NotNull=Not NULL

View File

@ -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);

View File

@ -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[]

View File

@ -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
|===

View File

@ -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[]