From 09589f1bef901183110534549e4f1884ba4523c5 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Fri, 30 Aug 2024 19:41:15 -0700 Subject: [PATCH 1/3] Ignore leading/trailing space in names when linking (closes #80) --- phpdotnet/phd/Format.php | 3 + tests/render/bug_GH-80.phpt | 103 ++++++++++++++++++++++++++++++++ tests/render/data/bug_GH-80.xml | 46 ++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 tests/render/bug_GH-80.phpt create mode 100644 tests/render/data/bug_GH-80.xml diff --git a/phpdotnet/phd/Format.php b/phpdotnet/phd/Format.php index f59e6a02..e4e5c7fd 100644 --- a/phpdotnet/phd/Format.php +++ b/phpdotnet/phd/Format.php @@ -270,12 +270,15 @@ public function getExamples() { return $this->examples; } public function getRefnameLink($ref) { + $ref = trim($ref); return isset($this->refs[$ref]) ? $this->refs[$ref] : null; } public function getClassnameLink($class) { + $class = trim($class); return isset($this->classes[$class]) ? $this->classes[$class] : null; } public function getVarnameLink($var) { + $var = trim($var); return isset($this->vars[$var]) ? $this->vars[$var] : null; } public function getGeneratedExampleID($index) { diff --git a/tests/render/bug_GH-80.phpt b/tests/render/bug_GH-80.phpt new file mode 100644 index 00000000..2b8d1dce --- /dev/null +++ b/tests/render/bug_GH-80.phpt @@ -0,0 +1,103 @@ +--TEST-- +GH-80: Be more lax in function/methodnames tag in regards to whitespace +--FILE-- +setXml_file($xml_file); +$config->setForce_index(true); + +$render = new Render(); + +$indexRepository = new IndexRepository(new \SQLite3(":memory:")); +$indexRepository->init(); +$config->set_indexcache($indexRepository); + +$index = new TestIndex($indexRepository, $config); +$render->attach($index); + +$reader = new Reader; +$reader->open($config->xml_file(), null, LIBXML_PARSEHUGE | LIBXML_XINCLUDE); +$render->execute($reader); + +$render->detach($index); + +$format = new TestPHPChunkedXHTML($config); +$render = new TestRender(new Reader, $config, $format); + +$render->run(); +?> +--EXPECT-- +Filename: test-function.html +Content: +
+
+

test_function

+
+

(No version information available, might only be in Git)

test_functionFor testing

+ +
+Filename: example.test-method.html +Content: +
+
+

Example::testMethod

+

(No version information available, might only be in Git)

Example::testMethodAn example method for testing

+ +
+
+Filename: test-class.html +Content: +
+
+ + class Example + {
+ }
+ +

Table of Contents

+
+ +Filename: test-variable.html +Content: +
+
+

$TEST_VARIABLE

+

(No version information available, might only be in Git)

$TEST_VARIABLEA test variable

+ +
+
+Filename: test-references.html +Content: +
+
+

+ test_function() should be linked. +

+

+ Example should be linked. +

+

+ Example::testMethod() should be linked. +

+

+ $TEST_VARIABLE should be linked. +

+
+ +
+Filename: test-references.html +Content: +
+ + + + + + + +
diff --git a/tests/render/data/bug_GH-80.xml b/tests/render/data/bug_GH-80.xml new file mode 100644 index 00000000..d3b0475a --- /dev/null +++ b/tests/render/data/bug_GH-80.xml @@ -0,0 +1,46 @@ + + + + test_function + + For testing + + + + + + Example + + + + + Example::testMethod + An example method for testing + + + + + + + $TEST_VARIABLE + A test variable + + + + + + + test_function should be linked. + + + Example should be linked. + + + Example::testMethod should be linked. + + + $TEST_VARIABLE should be linked. + + + + From 240f3a973f2b690341bc85b35a2c69540342490a Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Sat, 31 Aug 2024 11:00:29 -0700 Subject: [PATCH 2/3] Set namespace on top-level element --- tests/render/data/bug_GH-80.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/render/data/bug_GH-80.xml b/tests/render/data/bug_GH-80.xml index d3b0475a..0dd05271 100644 --- a/tests/render/data/bug_GH-80.xml +++ b/tests/render/data/bug_GH-80.xml @@ -1,4 +1,4 @@ - + test_function From e0edb9c6535f20cd862f55f9da7f66eb8016f460 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Sat, 31 Aug 2024 12:22:25 -0700 Subject: [PATCH 3/3] It is `` that sets the anchor for `` linking --- tests/render/bug_GH-80.phpt | 1 + tests/render/data/bug_GH-80.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/render/bug_GH-80.phpt b/tests/render/bug_GH-80.phpt index 2b8d1dce..2dcb53cb 100644 --- a/tests/render/bug_GH-80.phpt +++ b/tests/render/bug_GH-80.phpt @@ -53,6 +53,7 @@ Content: Filename: test-class.html Content:
+
class Example diff --git a/tests/render/data/bug_GH-80.xml b/tests/render/data/bug_GH-80.xml index 0dd05271..8c4fa171 100644 --- a/tests/render/data/bug_GH-80.xml +++ b/tests/render/data/bug_GH-80.xml @@ -7,6 +7,7 @@ + Example Example