diff --git a/README.md b/README.md index cec9a4a..2a6e3bf 100755 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ## Requirements -* SilverStripe 3.0 +* SilverStripe 3.1 ## Summary @@ -19,6 +19,29 @@ provides a web interface for viewing. To read documentation go to yoursite.com/dev/docs/ 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. + +### 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 +``` \ No newline at end of file diff --git a/code/extensions/DocumentationStaticPublisherExtension.php b/code/extensions/DocumentationStaticPublisherExtension.php new file mode 100644 index 0000000..80fb82e --- /dev/null +++ b/code/extensions/DocumentationStaticPublisherExtension.php @@ -0,0 +1,57 @@ + + * 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 that from being published. + * + * Again, in your applications config.yml file + * + * + * StaticExporter: + * disable_sitetree_export: true + * + * + * @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; + } + } + } + } + } + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 5f78476..89b8f22 100644 --- a/composer.json +++ b/composer.json @@ -15,5 +15,8 @@ }], "require": { "silverstripe/framework": "~3.1" - } + }, + "suggest": { + "silverstripe/staticpublisher": "Allows publishing documentation as HTML" + } }