Skip to content

Commit

Permalink
Add file modification history to PHP doc pages
Browse files Browse the repository at this point in the history
  • Loading branch information
haszi committed Apr 19, 2024
1 parent 40e35fe commit 16c85c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions phpdotnet/phd/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Config
'no_toc' => false,
'xml_root' => '.',
'xml_file' => './.manual.xml',
'history_file' => './fileModHistory.php',
'lang_dir' => './',
'language' => 'en',
'fallback_language' => 'en',
Expand Down
18 changes: 17 additions & 1 deletion phpdotnet/phd/Package/PHP/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class Package_PHP_Web extends Package_PHP_XHTML {

protected $sources = array();

/** $var array<string, array<string, mixed>> */
protected array $history = [];

public function __construct() {
parent::__construct();
$this->registerFormatName("PHP-Web");
Expand Down Expand Up @@ -78,6 +81,7 @@ public function update($event, $val = null) {
$this->loadSourcesInfo();
$this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . '/');
$this->postConstruct();
$this->loadHistoryInfo();
if (file_exists($this->getOutputDir())) {
if (!is_dir($this->getOutputDir())) {
v("Output directory is a file?", E_USER_ERROR);
Expand Down Expand Up @@ -182,6 +186,7 @@ public function header($id) {
"alternatives" => $this->cchunk["alternatives"],
"source" => $this->sourceInfo($id),
);
$setup["history"] = $this->history[$setup["source"]["path"]] ?? [];
if ($this->getChildren($id)) {
$lang = Config::language();
$setup["extra_header_links"] = array(
Expand All @@ -204,6 +209,8 @@ public function header($id) {
$setup["parents"] = $PARENTS;
manual_setup($setup);
contributors($setup);
?>
';
}
Expand Down Expand Up @@ -268,6 +275,15 @@ public function sourceInfo($id) {
}
return isset($this->sources[$id]) ? $this->sources[$id] : null;
}
}

public function loadHistoryInfo() {
if (!is_file(Config::phpweb_history_filename())) {
$this->history = [];
return;
}

$history = include Config::phpweb_history_filename();

$this->history = (is_array($history)) ? $history : [];
}
}
1 change: 1 addition & 0 deletions render.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"phpweb_version_filename" => Config::xml_root() . DIRECTORY_SEPARATOR . 'version.xml',
"phpweb_acronym_filename" => Config::xml_root() . DIRECTORY_SEPARATOR . 'entities' . DIRECTORY_SEPARATOR . 'acronyms.xml',
"phpweb_sources_filename" => Config::xml_root() . DIRECTORY_SEPARATOR . 'sources.xml',
"phpweb_history_filename" => Config::xml_root() . DIRECTORY_SEPARATOR . 'fileModHistory.php',
));
}

Expand Down

0 comments on commit 16c85c5

Please sign in to comment.