builddoc.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file scripts/modulebuilder/builddoc.php
  21. * \ingroup modulebuilder
  22. * \brief Script to build a documentation from input files (.asciidoc or .md files). Use asciidoctor tool.
  23. *
  24. * If file is a MD file, convert image links into asciidoc format.
  25. * ![Screenshot patient card](img/dolimed_screenshot_patientcard.png?raw=true "Patient card")
  26. * image:img/dolimed_screenshot_patientcard.png[Screenshot patient card]
  27. */
  28. $sapi_type = php_sapi_name();
  29. $script_file = basename(__FILE__);
  30. $path=dirname(__FILE__).'/';
  31. // Test if batch mode
  32. if (substr($sapi_type, 0, 3) == 'cgi') {
  33. echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
  34. exit(-1);
  35. }
  36. if (! isset($argv[1]) || ! $argv[1]) {
  37. print "Usage: ".$script_file." ModuleName\n";
  38. exit(-1);
  39. }
  40. $modulename=$argv[1];
  41. require_once $path."../../htdocs/master.inc.php";
  42. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  43. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  44. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
  45. require_once DOL_DOCUMENT_ROOT.'/core/lib/modulebuilder.lib.php';
  46. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  47. require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
  48. $langs->loadLangs(array("admin", "modulebuilder", "other", "cron"));
  49. // Global variables
  50. $version=DOL_VERSION;
  51. $error=0;
  52. // Dir for custom dirs
  53. $tmp=explode(',', $dolibarr_main_document_root_alt);
  54. $dirins = $tmp[0];
  55. $dirread = $dirins;
  56. $forceddirread = 0;
  57. $tmpdir = explode('@', $module);
  58. if (! empty($tmpdir[1]))
  59. {
  60. $module=$tmpdir[0];
  61. $dirread=$tmpdir[1];
  62. $forceddirread=1;
  63. }
  64. $FILEFLAG='modulebuilder.txt';
  65. $now=dol_now();
  66. $newmask = 0;
  67. if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
  68. if (empty($newmask)) // This should no happen
  69. {
  70. $newmask='0664';
  71. }
  72. /*
  73. * Main
  74. */
  75. @set_time_limit(0);
  76. print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
  77. print "modulename=".$modulename."\n";
  78. print "dirins=".$dirins."\n";
  79. $FILENAMEDOC=strtolower($module).'.html'; // TODO Use/text PDF
  80. $dirofmodule = dol_buildpath(strtolower($module), 0).'/doc';
  81. $outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC;
  82. $util = new Utils($db);
  83. $result = $util->generateDoc($module);
  84. if ($result <= 0)
  85. {
  86. print $util->errors;
  87. exit(1);
  88. }
  89. print $langs->trans("DocFileGeneratedInto", $outputfiledoc);
  90. exit(0);