Merge pull request #141 from Gautham/Dev

Add support for passing config.json and Output directory as parameters in CLI
This commit is contained in:
Denis Kisselev 2014-03-11 23:10:18 -07:00
commit d52fd0e5f5
6 changed files with 66 additions and 14 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules node_modules
.DS_Store .DS_Store
/sftp-config.json /sftp-config.json
static

View File

@ -15,6 +15,7 @@
* Git/SVN Friendly * Git/SVN Friendly
* Supports Google Analytics and Piwik Analytics * Supports Google Analytics and Piwik Analytics
* Optional code float layout * Optional code float layout
* Static Output Generation
## Demos ## Demos
@ -317,11 +318,12 @@ Generating a complete set of pages, with navigation
php index.php generate php index.php generate
``` ```
Generating just one big file with each doc concatenated You can optionally pass the location of config.json and (also optionally) the output directory for the static file
```bash ```bash
php index.php full-doc php index.php generate '\path\to\config.json' 'out\dir'
``` ```
If the directory has a '\' at the beginning, it is treated as an absolute path, otherwise as relative to the Daux Directory.
## Running on IIS ## Running on IIS

View File

@ -15,6 +15,7 @@
* Git/SVN Friendly * Git/SVN Friendly
* Supports Google Analytics and Piwik Analytics * Supports Google Analytics and Piwik Analytics
* Optional code float layout * Optional code float layout
* Static Output Generation
## Demos ## Demos
@ -22,6 +23,8 @@ This is a list of sites using Daux.io:
* [Daux.io](http://daux.io) * [Daux.io](http://daux.io)
* [Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation](http://mun.ee) * [Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation](http://mun.ee)
* [ICADMIN: An admin panel powered by CodeIgniter.](http://istocode.com/shared/ic-admin/)
* [Daux.io in Chinese - Demonstrates muti-language installations](http://daux.emx2.co.uk/)
Do you use Daux.io? Send me a pull request or open an [issue](https://github.com/justinwalsh/daux.io/issues) and I will add you to the list. Do you use Daux.io? Send me a pull request or open an [issue](https://github.com/justinwalsh/daux.io/issues) and I will add you to the list.
@ -131,13 +134,21 @@ To create a custom color scheme, set the `theme` property to `custom` and then d
``` ```
###Code Floating: ###Code Floating:
By deafult your code blocks will be floated to a column on the right side of your content. To disable this feature, set the `float` property to `false`. By default your code blocks will be floated to a column on the right side of your content. To disable this feature, set the `float` property to `false`.
```json ```json
{ {
"float": false "float": false
} }
``` ```
###Toggling Code Blocks
Some users might wish to hide the code blocks & view just the documentation. By setting the `toggle_code` property to `true`, you can offer a toggle button on the page.
```json
{
"toggle_code": true
}
```
###GitHub Repo: ###GitHub Repo:
@ -172,6 +183,8 @@ Include custom links in the sidebar.
``` ```
###File editor: ###File editor:
![File editor](https://f.cloud.github.com/assets/1788727/1954191/44358884-81d1-11e3-859d-254b9fb81808.png)
Enable front-end Markdown editor. _Disabled by default_. Enable front-end Markdown editor. _Disabled by default_.
```json ```json
@ -245,6 +258,37 @@ If your server does not have a default timezone set in php.ini, it may return er
} }
``` ```
###Multi-language
Enables multi-language support which needs seperate directories for each language in `docs/` folder.
```json
{
"languages": { "en": "English", "de": "German" }
}
```
Directory structure:
```
├── docs/
│ ├── index.md
│ ├── en
│ │ ├── 00_Getting_Started.md
│ │ ├── 01_Examples
│ │ │ ├── 01_GitHub_Flavored_Markdown.md
│ │ │ ├── 05_Code_Highlighting.md
│ │ ├── 05_More_Examples
│ │ │ ├── Hello_World.md
│ │ │ ├── 05_Code_Highlighting.md
│ ├── de
│ │ ├── 00_Getting_Started.md
│ │ ├── 01_Examples
│ │ │ ├── 01_GitHub_Flavored_Markdown.md
│ │ │ ├── 05_Code_Highlighting.md
│ │ ├── 05_More_Examples
│ │ │ ├── Hello_World.md
│ │ │ ├── 05_Code_Highlighting.md
```
## Running Remotely ## Running Remotely
Copy the files from the repo to a web server that can run PHP 5.3 or greater. Copy the files from the repo to a web server that can run PHP 5.3 or greater.
@ -274,12 +318,12 @@ Generating a complete set of pages, with navigation
php index.php generate php index.php generate
``` ```
Generating just one big file with each doc concatenated You can optionally pass the location of config.json and (also optionally) the output directory for the static file
```bash ```bash
php index.php full-doc php index.php generate '\path\to\config.json' 'out\dir'
``` ```
If the directory has a '\' at the beginning, it is treated as an absolute path, otherwise as relative to the Daux Directory.
## Running on IIS ## Running on IIS

View File

@ -75,7 +75,7 @@ if(isset($argv)){
switch ($argv[1]) { switch ($argv[1]) {
//Generate static web documentation //Generate static web documentation
case 'generate': case 'generate':
generate_static(); generate_static((isset($argv[3])) ? $argv[3] : '');
echo "Finished\n"; echo "Finished\n";
echo "The documentation is generated in static folder\n"; echo "The documentation is generated in static folder\n";
break; break;

View File

@ -3,12 +3,12 @@
require_once(dirname( __FILE__)."/markdown_extended.php"); require_once(dirname( __FILE__)."/markdown_extended.php");
$tree = array(); $tree = array();
$base = dirname(dirname(__FILE__)); $base = dirname(dirname(__FILE__));
$options = get_options(); $options = get_options(isset($argv[2]) ? $argv[2] : '');
$docs_path = $base . '/' . $options['docs_path']; $docs_path = $base . '/' . $options['docs_path'];
$multilanguage = !empty($options['languages']) ? TRUE : FALSE; $multilanguage = !empty($options['languages']) ? TRUE : FALSE;
// Options // Options
function get_options() { function get_options($config_file) {
global $base; global $base;
$options = array( $options = array(
'title' => "Documentation", 'title' => "Documentation",
@ -33,7 +33,8 @@
'template' => 'default' 'template' => 'default'
); );
// Load User Config // Load User Config
$config_file = $base . '/docs/config.json'; $config_file = (($config_file === '') ? 'docs/config.json' : $config_file);
if (substr($config_file, 0, 1) !== '/') $config_file = $base . '/' . $config_file;
if (file_exists($config_file)) { if (file_exists($config_file)) {
$config = json_decode(file_get_contents($config_file), true); $config = json_decode(file_get_contents($config_file), true);
$options = array_merge($options, $config); $options = array_merge($options, $config);
@ -53,6 +54,7 @@
exit; exit;
} }
} }
if (!ini_get('date.timezone')) date_default_timezone_set('GMT');
return $options; return $options;
} }
@ -143,7 +145,6 @@
if (!$file) { if (!$file) {
$page['path'] = ''; $page['path'] = '';
$page['markdown'] = ''; $page['markdown'] = '';
$page['content'] = '';
$page['title'] = 'Oh No'; $page['title'] = 'Oh No';
$page['content'] = "<h3>Oh No. That page doesn't exist</h3>"; $page['content'] = "<h3>Oh No. That page doesn't exist</h3>";
$options['file_editor'] = false; $options['file_editor'] = false;

View File

@ -1,10 +1,14 @@
<?php <?php
// Generate Static Documentation // Generate Static Documentation
function generate_static() { function generate_static($out_dir) {
global $tree, $base, $docs_path, $output_path, $options, $mode, $multilanguage, $output_language; global $tree, $base, $docs_path, $output_path, $options, $mode, $multilanguage, $output_language;
$mode = 'Static'; $mode = 'Static';
$output_path = $base . '/static'; if ($out_dir === '') $output_path = $base . '/static';
else {
if (substr($out_dir, 0, 1) !== '/') $output_path = $base . '/' . $out_dir;
else $output_path = $out_dir;
}
clean_copy_assets($output_path); clean_copy_assets($output_path);
build_tree(); build_tree();
if (!$multilanguage) generate_static_branch($tree, ''); if (!$multilanguage) generate_static_branch($tree, '');