Merge pull request #24287 from lamrani002/deleteFromDocMB

NEW functionality delete table of property from documentation
This commit is contained in:
Laurent Destailleur
2023-05-03 11:32:32 +02:00
committed by GitHub
2 changed files with 31 additions and 0 deletions

View File

@@ -613,6 +613,7 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
}
// end table
$table .= "|===";
$table .= "__ end table for object $objectname";
//write in file
$writeInFile = dolReplaceInFile($destfile, array('== DATA SPECIFICATIONS'=> $table));
if ($writeInFile<0) {
@@ -621,6 +622,23 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
return 1;
}
/**
* Delete property from documentation if we delete object
* @param string $file file or path
* @param string $objectname name of object wants to deleted
* @return void
*/
function deletePropsFromDoc($file, $objectname)
{
$start = "== Table of fields and their properties for object *".ucfirst($objectname)."* : ";
$end = "__ end table for object ".ucfirst($objectname);
$str = file_get_contents($file);
$search = '/' . preg_quote($start, '/') . '(.*?)' . preg_quote($end, '/') . '/s';
$new_contents = preg_replace($search, '', $str);
file_put_contents($file, $new_contents);
}
/**
* Search a string and return all lines needed from file
* @param string $file file for searching