t3docs/fluid-documentation-generator
Generates automatic TYPO3 Fluid ViewHelper reference docs in RST plus a JSON index. Configured via one or more JSON files and run from a CLI command to build navigable namespace/group/file structure for rendering with render-guides.
composer require --dev t3docs/fluid-documentation-generator
viewhelpers_config.json):
{
"name": "MyLaravelPackage",
"namespaceAlias": "laravel",
"targetNamespace": "http://typo3.org/ns/Vendor/MyLaravelPackage/ViewHelpers"
}
vendor/bin/fluidDocumentation generate path/to/viewhelpers_config.json
fluidDocumentationOutput/ (or custom dir via FLUID_DOCUMENTATION_OUTPUT_DIR).Document a custom Fluid ViewHelper in a Laravel/TYPO3 hybrid project:
src/ViewHelpers/MyCustomViewHelper.php) with proper PHPDoc annotations:
/**
* @param string $message
* @return string
*/
public function render($message) { ... }
Configuration-Driven Generation:
vendor/t3docs/fluid-documentation-generator/config/typo3/*).generate *.json).Integration with Laravel/TYPO3:
render-guides for RST-to-HTML rendering:
composer require --dev typo3/documentation-render-guides
vendor/bin/render-guides generate --source=fluidDocumentationOutput --target=docs/build/html
# .github/workflows/docs.yml
- name: Generate Documentation
run: vendor/bin/fluidDocumentation generate config/*.json
- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html
Template Customization:
vendor/t3docs/fluid-documentation-generator/src/Resources/templates/ to your project’s config/fluidDocumentation/templates/.Index.rst.j2, ViewHelper.rst.j2, or Namespace.rst.j2 to match your brand/style.JSON Output Utilization:
*.json file contains machine-readable metadata (e.g., ViewHelper signatures, parameters, examples).// Example: Fetch and parse JSON for a dynamic docs site
fetch('/docs/MyPackage.json')
.then(res => res.json())
.then(data => console.log(data.viewHelpers));
app/ViewHelpers/ and configure the generator to scan this directory:
{
"name": "LaravelApp",
"namespaceAlias": "app",
"targetNamespace": "http://typo3.org/ns/App/ViewHelpers",
"viewHelperPaths": ["app/ViewHelpers"]
}
// app/Console/Commands/GenerateViewHelperDocs.php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class GenerateViewHelperDocs extends Command {
protected $signature = 'docs:generate';
public function handle() {
$this->call('fluidDocumentation.generate', [
'config' => base_path('config/fluidDocumentation/*.json')
]);
}
}
Register it in app/Console/Kernel.php and run with:
php artisan docs:generate
Non-Fluid Projects:
No ViewHelpers found if your project lacks Fluid ViewHelpers.targetNamespace matches an actual PHP namespace containing ViewHelper classes.PHPDoc Annotations:
@param/@return tags → incomplete documentation.composer require --dev phpstan/phpstan
vendor/bin/phpstan analyse --level=5 --configuration=phpstan.neon
Output Directory Conflicts:
fluidDocumentationOutput/.FLUID_DOCUMENTATION_OUTPUT_DIR=/tmp/docs vendor/bin/fluidDocumentation generate config.json
Cross-Referencing Issues:
namespaceAlias uniqueness.Fluid Version Mismatch:
Unsupported Fluid version if your project uses Fluid <2.12.0.4.0.0).composer require --dev justinrainbow/json-schema
vendor/bin/json-schema-validator validate vendor/t3docs/fluid-documentation-generator/src/Config.schema.json config/viewhelpers_config.json
vendor/bin/fluidDocumentation generate config/test.json
vendor/bin/fluidDocumentation generate --verbose config.json
Custom RST Directives: Extend the JSON output schema to include Laravel-specific metadata (e.g., Blade component equivalents):
{
"viewHelpers": {
"MyViewHelper": {
"laravelEquivalent": "Blade::render('components/my-view-helper')"
}
}
}
Then modify render-guides to interpret this field.
Post-Processing Hooks: Use Laravel’s service providers to manipulate the generated RST/JSON:
// app/Providers/DocumentationServiceProvider.php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class DocumentationServiceProvider extends ServiceProvider {
public function boot() {
$this->app->afterResolving('fluidDocumentation', function ($generator) {
// Hook into the generation process
$generator->on('postGenerate', function ($outputDir) {
// Add custom RST files or modify existing ones
});
});
}
}
Dynamic Config Generation: Generate configs programmatically for Laravel packages:
// Generate config for all ViewHelpers in app/ViewHelpers/
$viewHelperPaths = [app_path('ViewHelpers')];
$config = [
"name" => "DynamicConfig",
"namespaceAlias" => "dynamic",
"targetNamespace" => "http://typo3.org/ns/App/DynamicViewHelpers",
"viewHelperPaths" => $viewHelperPaths
];
file_put_contents(base_path('config/fluidDocumentation/dynamic.json'), json_encode($config, JSON_PRETTY_PRINT));
{
"viewHelperPaths": ["app/ViewHelpers", "!tests/ViewHelpers"]
}
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Cache;
public function boot() {
Cache::remember('fluid_docs_json', now()->addDays(1), function () {
return json_decode(file_get_contents(storage_path('app/public/docs/MyPackage.json')), true);
});
}
How can I help you explore Laravel packages today?