NEW: Add static publisher option

This commit is contained in:
Will Rossiter 2014-01-14 20:41:59 +13:00
parent c8ba3ffd2a
commit 95b982353b
3 changed files with 86 additions and 3 deletions

View File

@ -9,7 +9,7 @@
## Requirements ## Requirements
* SilverStripe 3.0 * SilverStripe 3.1
## Summary ## Summary
@ -19,6 +19,29 @@ provides a web interface for viewing.
To read documentation go to yoursite.com/dev/docs/ To read documentation go to yoursite.com/dev/docs/
For more documentation on how to use the module please read /docs/Writing-Documentation.md For more documentation on how to use the module please read /docs/Writing-Documentation.md
(or via this in /dev/docs/sapphiredocs/Writing-Documentation in your webbrowser) (or via this in /dev/docs/docsviewer/Writing-Documentation in your webbrowser)
**Note** This module assumes you are using numeric values for your versions. **Note** This module assumes you are using numeric values for your versions.
### Static Publisher
If you wish to generate a truly static version of your documentation after it
has been rendered through the website, add the [Static Publisher](https://github.com/silverstripe-labs/silverstripe-staticpublisher)
module to your documentation project and set the following configuration in your
applications config.yml:
```
StaticExporter:
extensions:
- DocumentationStaticPublisherExtension
```
If you don't plan on using static publisher for anything else and you have the
cms module installed, make sure you disable the CMS from being published.
Again, in your applications config.yml file
```
StaticExporter:
disable_sitetree_export: true
```

View File

@ -0,0 +1,57 @@
<?php
/**
* An extension to StaticPublisher to enable exporting the documentation pages
* as HTML files to the server.
*
* If you want to add exporting functionality then install the static publisher
* module and set the following configuration in your applications config.yml:
*
* <code>
* StaticExporter:
* extensions:
* - DocumentationStaticPublisherExtension
* </code>
*
* If you don't plan on using static publisher for anything else and you have
* the cms module installed, make sure you disable that from being published.
*
* Again, in your applications config.yml file
*
* <code>
* StaticExporter:
* disable_sitetree_export: true
* </code>
*
* @package docsviewer
*/
class DocumentationStaticPublisherExtension extends Extension {
public function alterExportUrls(&$urls) {
// fetch all the documentation pages for all the registered modules
$modules = DocumentationService::get_registered_entities();
foreach($modules as $module) {
foreach($module->getLanguages() as $lang) {
foreach($module->getVersions() as $version) {
$pages = DocumentationService::get_pages_from_folder(
$module,
false,
true,
$version,
$lang
);
if($pages) {
foreach($pages as $page) {
$link = $page->getLink(false);
$urls[$link] = $link;
}
}
}
}
}
}
}

View File

@ -15,5 +15,8 @@
}], }],
"require": { "require": {
"silverstripe/framework": "~3.1" "silverstripe/framework": "~3.1"
},
"suggest": {
"silverstripe/staticpublisher": "Allows publishing documentation as HTML"
} }
} }