Skip to content
This repository was archived by the owner on Nov 23, 2026. It is now read-only.

Commit 7fd0a14

Browse files
committed
Require DOCS_PROJECT_PATH as the only source
1 parent 8b8eb21 commit 7fd0a14

5 files changed

Lines changed: 32 additions & 50 deletions

File tree

‎.env.dist‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
# Documentation Conversion Environment Configuration
22
# Copy this file to .env and modify as needed for your local setup
33

4-
# Documentation source type: 'local' or 'project'
5-
# 'local' - Use the docs-rst folder in this project
6-
# 'project' - Use docs from a CodeIgniter4 project directory
7-
DOCS_SOURCE_TYPE=local
8-
9-
# Path to CodeIgniter4 project user_guide_src directory
10-
# This should point to the user_guide_src/source folder in a CI4 project
11-
# Only used when DOCS_SOURCE_TYPE=project
4+
# Path to the user_guide_src/source folder of a CodeIgniter4 checkout
125
# Example: /path/to/CodeIgniter4/user_guide_src/source/
136
DOCS_PROJECT_PATH=

‎.github/workflows/verify.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ jobs:
6060
6161
- name: Convert
6262
env:
63-
DOCS_SOURCE_TYPE: project
6463
DOCS_PROJECT_PATH: ${{ github.workspace }}/ci4/user_guide_src/source/
6564
run: php admin/convert.php > convert.log 2>&1
6665

‎README.md‎

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,38 @@
11
# CodeIgniter Documentation Project
22

3-
The aim of this project is to convert the CodeIgniter User Guide from the existing reStructuredText format to Markdown format,
4-
making it easier to maintain and contribute to, as well as allowing all of our projects to share a common documentation format.
3+
The aim of this project is to convert the CodeIgniter User Guide from the existing reStructuredText format
4+
to Markdown format, making it easier to maintain and contribute to, as well as allowing all of our projects
5+
to share a common documentation format.
56

67
## Configuration
78

8-
The converter can work with two different source types:
9-
10-
1. **Local docs-rst folder** (default) - Uses the `docs-rst` folder in this project
11-
2. **CodeIgniter4 project** - Points to a CodeIgniter4 project's `user_guide_src/source` folder for latest docs
12-
13-
To configure, copy `.env.dist` to `.env` and modify as needed:
9+
The converter reads the user guide from the `user_guide_src/source` folder of a CodeIgniter4 checkout.
10+
To configure it, copy `.env.dist` to `.env` and set the path:
1411

1512
```bash
1613
cp .env.dist .env
17-
```
18-
19-
Example configurations:
2014

21-
**For local docs-rst (default):**
22-
```bash
23-
DOCS_SOURCE_TYPE=local
24-
DOCS_PROJECT_PATH=
25-
```
26-
27-
**For CodeIgniter4 project:**
28-
```bash
29-
DOCS_SOURCE_TYPE=project
3015
DOCS_PROJECT_PATH=/path/to/CodeIgniter4/user_guide_src/source/
3116
```
3217

33-
Environment variables of the same names take precedence over `.env`.
18+
An environment variable of the same name takes precedence over `.env`.
3419

3520
## The Conversion Process
3621

3722
The conversion process is being done using pandoc to do the initial conversion.
3823
From there, each section and file will be manually reviewed and cleaned up as needed.
3924

40-
Once the conversion is complete, we will start taking a look at the overall structure of the documentation and see what changes need
41-
to be made for consistency, clarity, and ease of understanding.
25+
Once the conversion is complete, we will start taking a look at the overall structure of the documentation
26+
and see what changes need to be made for consistency, clarity, and ease of understanding.
4227

4328
## Requirements
4429

45-
To convert, pandoc 3.12.1 is required. The converter warns when another version is installed. To install it, see <https://github.com/jgm/pandoc/releases/tag/3.12.1>.
30+
To convert, pandoc 3.12.1 is required. The converter warns when another version is installed.
31+
To install it, see <https://github.com/jgm/pandoc/releases/tag/3.12.1>.
4632

47-
Generation of the final documentation uses [MkDocs](https://www.mkdocs.org/) with the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme. See [How to Build Docs](./admin/how_to_build_docs.md) for more details.
33+
Generation of the final documentation uses [MkDocs](https://www.mkdocs.org/) with the
34+
[Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme.
35+
See [How to Build Docs](./admin/how_to_build_docs.md) for more details.
4836

4937
## Next Steps:
5038

@@ -90,4 +78,5 @@ The [Verify conversion](./.github/workflows/verify.yml) workflow runs both again
9078

9179
### Previewing the converted files
9280

93-
See the [How to Build Docs](./admin/how_to_build_docs.md) document for instructions on building and previewing the converted files.
81+
See the [How to Build Docs](./admin/how_to_build_docs.md) document for instructions on building
82+
and previewing the converted files.

‎admin/convert.php‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
function loadEnvConfig(): array {
99
$envFile = __DIR__ . '/../.env';
1010
$config = [
11-
'DOCS_SOURCE_TYPE' => 'local',
12-
'DOCS_PROJECT_PATH' => ''
11+
'DOCS_PROJECT_PATH' => '',
1312
];
1413

1514
if (file_exists($envFile)) {
@@ -52,19 +51,22 @@ function writeLine(string $message, string $style = '', $stream = STDOUT): void
5251
}
5352

5453
function getSourceDirectory(): string {
55-
$config = loadEnvConfig();
56-
57-
if ($config['DOCS_SOURCE_TYPE'] === 'project' && !empty($config['DOCS_PROJECT_PATH'])) {
58-
$projectPath = rtrim($config['DOCS_PROJECT_PATH'], '/') . '/';
59-
if (!is_dir($projectPath)) {
60-
writeLine(sprintf('Error: Project path does not exist: %s', $projectPath), STYLE_ERROR, STDERR);
61-
writeLine('Please check your .env file configuration.', '', STDERR);
62-
exit(1);
63-
}
64-
return $projectPath;
54+
$projectPath = loadEnvConfig()['DOCS_PROJECT_PATH'];
55+
56+
if ($projectPath === '') {
57+
writeLine('Error: DOCS_PROJECT_PATH is not set.', STYLE_ERROR, STDERR);
58+
writeLine('Set it in the environment or in .env to the user_guide_src/source folder of a CodeIgniter4 checkout.', '', STDERR);
59+
exit(1);
60+
}
61+
62+
$projectPath = rtrim($projectPath, '/') . '/';
63+
64+
if (!is_dir($projectPath)) {
65+
writeLine(sprintf('Error: DOCS_PROJECT_PATH does not exist: %s', $projectPath), STYLE_ERROR, STDERR);
66+
exit(1);
6567
}
6668

67-
return __DIR__ . '/../docs-rst/';
69+
return $projectPath;
6870
}
6971

7072
function checkPandocVersion(): void {

‎admin/filters/toctree.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ function getSubdirectoryToctree(string $subdirPath, string $folder): ?array {
213213
function getFirstHeaderFromFile(string $filename, string $folder): ?string {
214214
$targetFile = '';
215215

216-
$docsRstPath = realpath($folder);
217-
$docsPath = str_replace('/docs-rst/', '/docs/', $docsRstPath . '/');
216+
$docsPath = realpath($folder) . '/';
218217

219218
if (strpos($filename, '../') === 0) {
220219
$relativePath = substr($filename, 3);

0 commit comments

Comments
 (0)