From 61910bc38a55aaab8f64f54738af541331f6fc73 Mon Sep 17 00:00:00 2001 From: Andrew Matsovkin Date: Wed, 29 Jun 2016 22:11:03 +0300 Subject: [PATCH 1/6] Add composer depdenency for geshi and update phpdoc to pull in geshi from composer vendor branch when it exists --- composer.json | 3 ++- phpdoc.php | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 21568a9..ccf28f4 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ ], "require": { "php": ">=5.2.0", - "michelf/php-markdown": "1.3" + "michelf/php-markdown": "1.3", + "easybook/geshi" : "*" }, "require-dev": { "lastcraft/simpletest": "1.1.*" diff --git a/phpdoc.php b/phpdoc.php index f9f1803..455d061 100755 --- a/phpdoc.php +++ b/phpdoc.php @@ -24,7 +24,7 @@ // check we are running from the command line if (!isset($argv[0])) { die('This program must be run from the command line using the CLI version of PHP'); - + // check we are using the correct version of PHP } elseif (!defined('T_COMMENT') || !extension_loaded('tokenizer') || version_compare(phpversion(), '5', '<')) { error('You need PHP version 5 or greater with the "tokenizer" extension to run this script, please upgrade'); @@ -35,6 +35,12 @@ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__)); require('classes'.DIRECTORY_SEPARATOR.'phpDoctor.php'); +// include geshi from composer if it exists +$phpg = 'vendor'.DIRECTORY_SEPARATOR.'easybook'.DIRECTORY_SEPARATOR.'geshi'.DIRECTORY_SEPARATOR.'geshi.php'; +if (is_readable($phpg)) { + include($phpg); +} + // get name of config file to use if (!isset($argv[1])) { if (isset($_ENV['PHPDoctor'])) { From 198be2f965983dc8f683ad2932bb4d4a01a0816b Mon Sep 17 00:00:00 2001 From: Andrew Matsovkin Date: Wed, 29 Jun 2016 22:16:27 +0300 Subject: [PATCH 2/6] Fix #76 Converts HTML entities in sources to safe display --- doclets/standard/sourceWriter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doclets/standard/sourceWriter.php b/doclets/standard/sourceWriter.php index 1ff39de..712af74 100644 --- a/doclets/standard/sourceWriter.php +++ b/doclets/standard/sourceWriter.php @@ -90,7 +90,7 @@ public function sourceWriter(&$doclet) $geshi = new GeSHi($data[0], 'php'); $source = $geshi->parse_code(); } else { - $source = '
'.$data[0].'
'; + $source = '
'.htmlspecialchars($data[0]).'
'; } ob_start(); From 5394ce40782e41a20463032f6ee74f2136e48377 Mon Sep 17 00:00:00 2001 From: Andrew Matsovkin Date: Thu, 30 Jun 2016 02:04:15 +0300 Subject: [PATCH 3/6] Fix #77 broken paths on windows --- classes/phpDoctor.php | 4 ++-- doclets/standard/htmlWriter.php | 2 +- doclets/standard/sourceWriter.php | 2 +- phpdoc.php | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/classes/phpDoctor.php b/classes/phpDoctor.php index 6af5ac3..9fc50fd 100644 --- a/classes/phpDoctor.php +++ b/classes/phpDoctor.php @@ -269,7 +269,7 @@ public function phpDoctor($config = 'default.ini') if (isset($this->_options['source_path'])) { $this->_sourcePath = array(); foreach (explode(',', $this->_options['source_path']) as $path) { - $this->_sourcePath[] = $this->fixPath($path, getcwd()); + $this->_sourcePath[] = $this->makeAbsolutePath($path, getcwd()); } } @@ -487,7 +487,7 @@ public function makeAbsolutePath($path, $prefix) public function fixPath($path) { if (substr($path, -1, 1) != '/' && substr($path, -1, 1) != '\\') { - return $path.'/'; + return $path.DIRECTORY_SEPARATOR; } else { return $path; } diff --git a/doclets/standard/htmlWriter.php b/doclets/standard/htmlWriter.php index 4234b7b..510ff11 100644 --- a/doclets/standard/htmlWriter.php +++ b/doclets/standard/htmlWriter.php @@ -168,7 +168,7 @@ public function _nav($path) $output .= '\n"; $thisClass = strtolower(get_class($this)); if ($thisClass == 'classwriter') { diff --git a/doclets/standard/sourceWriter.php b/doclets/standard/sourceWriter.php index 712af74..bcf5423 100644 --- a/doclets/standard/sourceWriter.php +++ b/doclets/standard/sourceWriter.php @@ -84,7 +84,7 @@ public function sourceWriter(&$doclet) $this->_sections[7] = array('title' => 'Todo', 'url' => 'todo-list.html'); $this->_sections[8] = array('title' => 'Index', 'url' => 'index-all.html'); - $this->_depth = substr_count($filename, '/') + 1; + $this->_depth = substr_count(str_replace('\\', '/', $filename), '/') + 1; if (class_exists('GeSHi')) { $geshi = new GeSHi($data[0], 'php'); diff --git a/phpdoc.php b/phpdoc.php index 455d061..dfdd401 100755 --- a/phpdoc.php +++ b/phpdoc.php @@ -45,10 +45,10 @@ if (!isset($argv[1])) { if (isset($_ENV['PHPDoctor'])) { $argv[1] = $_ENV['PHPDoctor']; - } elseif (is_file(getcwd().'/phpdoctor.ini')) { - $argv[1] = getcwd().'/phpdoctor.ini'; - } elseif (is_file(dirname(__FILE__).'/phpdoctor.ini')) { - $argv[1] = dirname(__FILE__).'/phpdoctor.ini'; + } elseif (is_file(getcwd().DIRECTORY_SEPARATOR.'phpdoctor.ini')) { + $argv[1] = getcwd().DIRECTORY_SEPARATOR.'phpdoctor.ini'; + } elseif (is_file(dirname(__FILE__).DIRECTORY_SEPARATOR.'phpdoctor.ini')) { + $argv[1] = dirname(__FILE__).DIRECTORY_SEPARATOR.'phpdoctor.ini'; } else { die("Usage: phpdoc [config_file]\n"); } From 88f04dffaad552aa72db6f3baa5665a4eb42651c Mon Sep 17 00:00:00 2001 From: Andrew Matsovkin Date: Thu, 30 Jun 2016 02:06:39 +0300 Subject: [PATCH 4/6] Addition fix to Geshi autoload --- doclets/standard/standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doclets/standard/standard.php b/doclets/standard/standard.php index a487055..5a21b4d 100644 --- a/doclets/standard/standard.php +++ b/doclets/standard/standard.php @@ -142,7 +142,7 @@ public function standard(&$rootDoc, $formatter) if (isset($options['include_source'])) $this->_includeSource = $options['include_source']; if ($this->_includeSource) { - @include_once 'geshi/geshi.php'; + if (!class_exists('GeSHi')) @include_once 'geshi/geshi.php'; if (!class_exists('GeSHi')) { $phpdoctor->warning('Could not find GeSHi in "geshi/geshi.php", not pretty printing source'); } From 9d7817fdc4b389d388660ebdcdfde03f506aae83 Mon Sep 17 00:00:00 2001 From: Andrew Matsovkin Date: Thu, 30 Jun 2016 07:29:26 +0300 Subject: [PATCH 5/6] Fix to use Composer autoloader --- phpdoc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpdoc.php b/phpdoc.php index dfdd401..e572661 100755 --- a/phpdoc.php +++ b/phpdoc.php @@ -35,10 +35,10 @@ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__)); require('classes'.DIRECTORY_SEPARATOR.'phpDoctor.php'); -// include geshi from composer if it exists -$phpg = 'vendor'.DIRECTORY_SEPARATOR.'easybook'.DIRECTORY_SEPARATOR.'geshi'.DIRECTORY_SEPARATOR.'geshi.php'; -if (is_readable($phpg)) { - include($phpg); +// include Composer autoloader +$autoloader = dirname(__FILE__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php'; +if (is_readable($autoloader)) { + include($autoloader); } // get name of config file to use From a4cbff6a8193ec540b9dfecbe3ab6762c4c2fa34 Mon Sep 17 00:00:00 2001 From: Andrew Matsovkin Date: Thu, 30 Jun 2016 13:15:43 +0300 Subject: [PATCH 6/6] Autoloader fix --- phpdoc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpdoc.php b/phpdoc.php index e572661..2313722 100755 --- a/phpdoc.php +++ b/phpdoc.php @@ -38,7 +38,7 @@ // include Composer autoloader $autoloader = dirname(__FILE__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php'; if (is_readable($autoloader)) { - include($autoloader); + require_once($autoloader); } // get name of config file to use