diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 074b38bfc2d50ed88a4e0464f607472b328b845b..a785b55a5ec73626c5c0079d79d3cf226e128b2f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -51,10 +51,11 @@ function dol_basename($pathfile) * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @param int $nohook Disable all hooks + * @param string $relativename For recursive purpose only. Must be "" at first call. * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) * @see dol_dir_list_indatabase */ -function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0) +function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="") { global $db, $hookmanager; global $object; @@ -144,6 +145,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil "name" => $file, "path" => $path, "level1name" => $level1name, + "relativename" => ($relativename?$relativename.'/':'').$file, "fullname" => $path.'/'.$file, "date" => $filedate, "size" => $filesize, @@ -155,7 +157,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil // if we're in a directory and we want recursive behavior, call this function again if ($recursive) { - $file_list = array_merge($file_list,dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook)); + $file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename?$relativename.'/':'').$file)); } } else if (! $isdir && (($types == "files") || ($types == "all"))) @@ -172,6 +174,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil "name" => $file, "path" => $path, "level1name" => $level1name, + "relativename" => ($relativename?$relativename.'/':'').$file, "fullname" => $path.'/'.$file, "date" => $filedate, "size" => $filesize, diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index bbaf00dcaf4511d085c31be3d12a185fa2b6db85..9a7fbb7b3bc9c60cb4d1052c29c1aaf47a9cf337 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -12,7 +12,7 @@ ModuleInitialized=Module initialized FilesForObjectInitialized=Files for new object '%s' initialized FilesForObjectUpdated=Files for object '%s' updated (.sql files and .class.php file) ModuleBuilderDescdescription=Enter here all general information that describe your module -ModuleBuilderDescspecifications=You can enter here a long text to describe the specifications of your module that is not already structured into other tabs. So you have within easy reach all the rules to develop. Also this text content will be included into the generated documentation (see last tab). +ModuleBuilderDescspecifications=You can enter here a long text to describe the specifications of your module that is not already structured into other tabs. So you have within easy reach all the rules to develop. Also this text content will be included into the generated documentation (see last tab). You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown) ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A sql file, a page to list them, to create/edit/view a card and an API will be generated. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module. @@ -52,4 +52,5 @@ ReadmeFile=Readme file ChangeLog=ChangeLog file SqlFile=Sql file SqlFileKey=Sql file for keys -AnObjectAlreadyExistWithThisNameAndDiffCase=An object already exists with this name and a different case \ No newline at end of file +AnObjectAlreadyExistWithThisNameAndDiffCase=An object already exists with this name and a different case +UseAsciiDocFormat=You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown) \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 2399ce4124648c4bef9b4a1ee589b8e1ec3f1e1b..359c46f17ae007a37a0cb6ac3893afb2f92f52cb 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -924,20 +924,26 @@ elseif (! empty($module)) if ($tab == 'specifications') { - $pathtofile = $modulelowercase.'/SPECIFICATIONS.md'; - if ($action != 'editfile' || empty($file)) { - print '<span class="fa fa-file"></span> '.$langs->trans("SpecificationFile").' : <strong>'.$pathtofile.'</strong>'; - print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; - print '<br>'; + $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$'); - // Use MD or asciidoc - //print 'http://asciidoctor.org/docs/user-manual/#compared-to-markdown'; + foreach ($specs as $spec) + { + $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; + + print '<span class="fa fa-file"></span> '.$langs->trans("SpecificationFile").' : <strong>'.$pathtofile.'</strong>'; + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; + print '<br>'; + } } else { - $fullpathoffile=dol_buildpath($file, 0); + // Use MD or asciidoc + + //print $langs->trans("UseAsciiDocFormat").'<br>'; + + $fullpathoffile=dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); diff --git a/htdocs/modulebuilder/template/SPECIFICATIONS.md b/htdocs/modulebuilder/template/doc/Specifications.asciidoc similarity index 100% rename from htdocs/modulebuilder/template/SPECIFICATIONS.md rename to htdocs/modulebuilder/template/doc/Specifications.asciidoc