mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Add script to generate issues.md.
This commit is contained in:
parent
6d385fd8f0
commit
ceb5644d5b
24
bin/generate_issues_list_doc.php
Executable file
24
bin/generate_issues_list_doc.php
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
$docs_dir = dirname(__DIR__) . DIRECTORY_SEPARATOR . "docs" . DIRECTORY_SEPARATOR . "running_psalm" . DIRECTORY_SEPARATOR;
|
||||
$issues_index = "{$docs_dir}issues.md";
|
||||
$issues_dir = "{$docs_dir}issues";
|
||||
|
||||
if (!file_exists($issues_dir)) {
|
||||
throw new UnexpectedValueException("Issues documentation not found");
|
||||
}
|
||||
|
||||
$issues_list = array_filter(array_map(function (string $issue_file) {
|
||||
if ($issue_file === "." || $issue_file === ".." || substr($issue_file, -3) !== ".md") {
|
||||
return false;
|
||||
}
|
||||
|
||||
$issue = substr($issue_file, 0, strlen($issue_file) - 3);
|
||||
return " - [$issue](issues/$issue.md)";
|
||||
}, scandir($issues_dir)));
|
||||
|
||||
usort($issues_list, "strcasecmp");
|
||||
|
||||
$issues_md_contents = array_merge(["# Issue types", ""], $issues_list, [""]);
|
||||
file_put_contents($issues_index, implode("\n", $issues_md_contents));
|
@ -99,7 +99,7 @@ class DocumentationTest extends TestCase
|
||||
*/
|
||||
private static function getCodeBlocksFromDocs(): array
|
||||
{
|
||||
$issues_dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . 'running_psalm' . DIRECTORY_SEPARATOR . 'issues';
|
||||
$issues_dir = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . 'running_psalm' . DIRECTORY_SEPARATOR . 'issues';
|
||||
|
||||
if (!file_exists($issues_dir)) {
|
||||
throw new UnexpectedValueException('docs not found');
|
||||
@ -432,9 +432,13 @@ class DocumentationTest extends TestCase
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that issues.md contains the expected links to issue documentation.
|
||||
* issues.md can be generated automatically with bin/generate_documentation_issues_list.php.
|
||||
*/
|
||||
public function testIssuesIndex(): void
|
||||
{
|
||||
$docs_dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "docs" . DIRECTORY_SEPARATOR . "running_psalm" . DIRECTORY_SEPARATOR;
|
||||
$docs_dir = dirname(__DIR__) . DIRECTORY_SEPARATOR . "docs" . DIRECTORY_SEPARATOR . "running_psalm" . DIRECTORY_SEPARATOR;
|
||||
$issues_index = "{$docs_dir}issues.md";
|
||||
$issues_dir = "{$docs_dir}issues";
|
||||
|
||||
@ -446,8 +450,6 @@ class DocumentationTest extends TestCase
|
||||
throw new UnexpectedValueException("Issues index not found");
|
||||
}
|
||||
|
||||
$issue_files = scandir($issues_dir);
|
||||
|
||||
$issues_index_contents = file($issues_index, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||
array_shift($issues_index_contents); // Remove title
|
||||
|
||||
@ -463,7 +465,7 @@ class DocumentationTest extends TestCase
|
||||
}
|
||||
$this->assertStringEndsWith(".md", $issue_file, "Invalid file in issues documentation: $issue_file");
|
||||
return substr($issue_file, 0, strlen($issue_file) - 3);
|
||||
}, $issue_files));
|
||||
}, scandir($issues_dir)));
|
||||
|
||||
$unlisted_issues = array_diff($issue_files, $issues_index_list);
|
||||
$this->assertEmpty($unlisted_issues, "Issue documentation missing from issues.md: " . implode(", ", $unlisted_issues));
|
||||
|
Loading…
x
Reference in New Issue
Block a user