2012-04-08 11:36:16 +02:00
|
|
|
# docsviewer Module
|
2010-06-24 16:22:41 +02:00
|
|
|
|
2012-04-08 11:23:49 +02:00
|
|
|
This module has been developed to read and display content from markdown and
|
|
|
|
plain text files in web browser. It provides an easy way to bundle end user
|
|
|
|
documentation within a SilverStripe installation or module.
|
2010-06-24 16:22:41 +02:00
|
|
|
|
2012-04-08 11:23:49 +02:00
|
|
|
## Setup
|
|
|
|
|
|
|
|
The module includes the ability to read documentation from any folder on your
|
|
|
|
file system. By standard, documentation should go in a __docs__ folder in the
|
|
|
|
root of your module or project documentation.
|
|
|
|
|
|
|
|
### Standard
|
|
|
|
|
|
|
|
If you follow the standard setup create a file in /<<module>>/__docs/_en/index.md__
|
|
|
|
file then include the following in your config file:
|
|
|
|
|
|
|
|
DocumentationService::set_automatic_registration(true);
|
|
|
|
|
|
|
|
Now visit yoursite.com/dev/docs you should see your module.
|
|
|
|
|
|
|
|
### Custom Folders
|
|
|
|
|
|
|
|
If you wish to register specific folders only, or folders in a non standard
|
|
|
|
location then you can register paths directly:
|
2010-06-24 16:22:41 +02:00
|
|
|
|
2012-04-08 11:23:49 +02:00
|
|
|
try {
|
|
|
|
DocumentationService::register(
|
|
|
|
$name = "sapphire",
|
|
|
|
$path = "/src/sapphire_master/docs/",
|
|
|
|
$version = 'trunk'
|
|
|
|
);
|
|
|
|
} catch(InvalidArgumentException $e) {
|
|
|
|
// Silence if path is not found (for CI environment)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
To configure the documentation system the configuration information is
|
2012-05-25 01:47:24 +02:00
|
|
|
available on the [Configurations](configuration-options)
|
2010-06-24 16:22:41 +02:00
|
|
|
page.
|
|
|
|
|
2012-04-08 11:23:49 +02:00
|
|
|
## Writing documentation
|
|
|
|
|
2012-05-25 01:47:24 +02:00
|
|
|
See [Writing Documentation](writing-documentation)
|
2012-04-08 11:23:49 +02:00
|
|
|
for more information on how to write markdown files which are available here.
|
2010-08-01 06:46:41 +02:00
|
|
|
|
2011-01-11 02:35:59 +01:00
|
|
|
|
2012-04-08 11:23:49 +02:00
|
|
|
## Enabling Search
|
|
|
|
|
|
|
|
The module provides automatic search functionality via [Lucene Search](http://lucene.apache.org/java/docs/index.html).
|
|
|
|
|
|
|
|
To enable search you need to add the following to your applications _config.php
|
|
|
|
file:
|
2011-01-11 02:35:59 +01:00
|
|
|
|
|
|
|
DocumentationSearch::enable();
|
|
|
|
|
2012-04-08 11:23:49 +02:00
|
|
|
After adding that line you will also need to build the indexes of the search.
|
|
|
|
|
|
|
|
You can do this either via your web browser by accessing
|
2011-01-11 02:35:59 +01:00
|
|
|
|
2011-03-12 05:11:21 +01:00
|
|
|
http://yoursite.com/dev/tasks/RebuildLuceneDocsIndex?flush=1
|
2011-01-11 02:35:59 +01:00
|
|
|
|
2012-04-08 11:23:49 +02:00
|
|
|
Or rebuild it via sake. You will want to set this up as a cron job if your
|
|
|
|
documentation search needs to be updated on the fly
|
2011-03-12 05:11:21 +01:00
|
|
|
|
|
|
|
sake dev/tasks/RebuildLuceneDocsIndex flush=1
|
2011-01-11 02:35:59 +01:00
|
|
|
|
2013-01-07 17:26:39 +01:00
|
|
|
## Advanced Search
|
|
|
|
|
|
|
|
Advanced Search is enabled by default on the searchresults page, allowing you to
|
|
|
|
extend your search over multiple modules and/or versions. Advanced search can
|
|
|
|
be disabled from your _config.php like this:
|
|
|
|
|
|
|
|
DocumentationSearch::enable_advanced_search(false);
|
2011-01-11 02:35:59 +01:00
|
|
|
|
2012-04-08 11:23:49 +02:00
|
|
|
## Using a URL other than /dev/docs/
|
2011-01-11 02:35:59 +01:00
|
|
|
|
2012-04-08 11:23:49 +02:00
|
|
|
By default, the documentation is available in `dev/docs`. If you want it to
|
|
|
|
live on the webroot instead of a subfolder or on another url address, add the
|
|
|
|
following configuration to your _config.php file:
|
2010-08-01 06:46:41 +02:00
|
|
|
|
|
|
|
DocumentationViewer::set_link_base('');
|
2012-04-08 11:23:49 +02:00
|
|
|
|
2010-08-01 06:46:41 +02:00
|
|
|
Director::addRules(1, array(
|
|
|
|
'$Action' => 'DocumentationViewer',
|
|
|
|
'' => 'DocumentationViewer'
|
2011-01-11 02:35:59 +01:00
|
|
|
));
|