mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
NEW: Add static publisher option
This commit is contained in:
parent
c8ba3ffd2a
commit
95b982353b
27
README.md
27
README.md
@ -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
|
||||||
|
```
|
57
code/extensions/DocumentationStaticPublisherExtension.php
Normal file
57
code/extensions/DocumentationStaticPublisherExtension.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,5 +15,8 @@
|
|||||||
}],
|
}],
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "~3.1"
|
"silverstripe/framework": "~3.1"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"silverstripe/staticpublisher": "Allows publishing documentation as HTML"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user