Can setup tool to build html or pdf for module builder documentation

This commit is contained in:
Laurent Destailleur 2019-03-12 11:51:20 +01:00
parent 281bde5461
commit da2aba96eb
2 changed files with 41 additions and 8 deletions

View File

@ -611,7 +611,8 @@ class Utils
if (count($arrayversion)) if (count($arrayversion))
{ {
$FILENAMEASCII=strtolower($module).'.asciidoc'; $FILENAMEASCII=strtolower($module).'.asciidoc';
$FILENAMEDOC=strtolower($module).'.html'; // TODO Use/text PDF $FILENAMEDOC=strtolower($module).'.html';
$FILENAMEDOCPDF=strtolower($module).'.pdf';
$dirofmodule = dol_buildpath(strtolower($module), 0); $dirofmodule = dol_buildpath(strtolower($module), 0);
$dirofmoduledoc = dol_buildpath(strtolower($module), 0).'/doc'; $dirofmoduledoc = dol_buildpath(strtolower($module), 0).'/doc';
@ -627,8 +628,7 @@ class Utils
return -1; return -1;
} }
$conf->global->MODULEBUILDER_ASCIIDOCTOR='asciidoctor'; if (empty($conf->global->MODULEBUILDER_ASCIIDOCTOR) && empty($conf->global->MODULEBUILDER_ASCIIDOCTORPDF))
if (empty($conf->global->MODULEBUILDER_ASCIIDOCTOR))
{ {
$this->error = 'Setup of module ModuleBuilder not complete'; $this->error = 'Setup of module ModuleBuilder not complete';
return -1; return -1;
@ -690,11 +690,24 @@ class Utils
$currentdir = getcwd(); $currentdir = getcwd();
chdir($dirofmodule); chdir($dirofmodule);
require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
$utils = new Utils($db);
// Build HTML doc
$command=$conf->global->MODULEBUILDER_ASCIIDOCTOR.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOC; $command=$conf->global->MODULEBUILDER_ASCIIDOCTOR.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOC;
$outfile=$dirofmoduletmp.'/out.tmp'; $outfile=$dirofmoduletmp.'/out.tmp';
require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; $resarray = $utils->executeCLI($command, $outfile);
$utils = new Utils($db); if ($resarray['result'] != '0')
{
$this->error = $resarray['error'].' '.$resarray['output'];
}
$result = ($resarray['result'] == 0) ? 1 : 0;
// Build PDF doc
$command=$conf->global->MODULEBUILDER_ASCIIDOCTORPDF.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOC;
$outfile=$dirofmoduletmp.'/outpdf.tmp';
$resarray = $utils->executeCLI($command, $outfile); $resarray = $utils->executeCLI($command, $outfile);
if ($resarray['result'] != '0') if ($resarray['result'] != '0')
{ {

View File

@ -35,9 +35,12 @@ $backtopage = GETPOST('backtopage', 'alpha');
/* /*
* Actions * Actions
*/ */
if ($action=="update"){ if ($action=="update")
$res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README'), 'chaine', 0, '', $conf->entity); {
if ($res1 < 0) { $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'none'), 'chaine', 0, '', $conf->entity);
$res2=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity);
$res3=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity);
if ($res1 < 0 || $res2 < 0 || $res3 < 0) {
setEventMessages('ErrorFailedToSaveDate', null, 'errors'); setEventMessages('ErrorFailedToSaveDate', null, 'errors');
$db->rollback(); $db->rollback();
} }
@ -130,6 +133,23 @@ print '<td>';
print '<textarea class="centpercent" rows="20" name="MODULEBUILDER_SPECIFIC_README">'.$conf->global->MODULEBUILDER_SPECIFIC_README.'</textarea>'; print '<textarea class="centpercent" rows="20" name="MODULEBUILDER_SPECIFIC_README">'.$conf->global->MODULEBUILDER_SPECIFIC_README.'</textarea>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="oddeven">';
print '<td class="tdtop">' . $langs->trans("AsciiToHtmlConverter") . '</td>';
print '<td>';
print '<input type="text" name="MODULEBUILDER_ASCIIDOCTOR" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTOR.'">';
print ' '.$langs->trans("Example").': asciidoc, asciidoctor';
print '</td>';
print '</tr>';
print '<tr class="oddeven">';
print '<td class="tdtop">' . $langs->trans("AsciiToPdfConverter") . '</td>';
print '<td>';
print '<input type="text" name="MODULEBUILDER_ASCIIDOCTORPDF" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTORPDF.'">';
print ' '.$langs->trans("Example").': asciidoctor-pdf';
print '</td>';
print '</tr>';
print '</table>'; print '</table>';
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'" name="Button"></center>'; print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'" name="Button"></center>';