Skip to content

Commit

Permalink
Add support for passing config.json and Output directory as parameter…
Browse files Browse the repository at this point in the history
…s in CLI

Remove unnecessary line from libs/functions.php

Add './static' to gitignore

Add Default Timezone to prevent Date() Warnings
  • Loading branch information
Gautham committed Mar 8, 2014
1 parent c71a6e3 commit 33b8144
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.DS_Store
/sftp-config.json
/sftp-config.json
static
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Git/SVN Friendly
* Supports Google Analytics and Piwik Analytics
* Optional code float layout
* Static Output Generation

## Demos

Expand Down Expand Up @@ -317,11 +318,12 @@ Generating a complete set of pages, with navigation
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
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

Expand Down
52 changes: 48 additions & 4 deletions docs/00_Getting_Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
* Git/SVN Friendly
* Supports Google Analytics and Piwik Analytics
* Optional code float layout
* Static Output Generation

## Demos

This is a list of sites using Daux.io:

* [Daux.io](http://daux.io)
* [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.

Expand Down Expand Up @@ -131,13 +134,21 @@ To create a custom color scheme, set the `theme` property to `custom` and then d
```

###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
{
"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:
Expand Down Expand Up @@ -172,6 +183,8 @@ Include custom links in the sidebar.
```

###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_.

```json
Expand Down Expand Up @@ -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

Copy the files from the repo to a web server that can run PHP 5.3 or greater.
Expand Down Expand Up @@ -274,12 +318,12 @@ Generating a complete set of pages, with navigation
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
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

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
switch ($argv[1]) {
//Generate static web documentation
case 'generate':
generate_static();
generate_static((isset($argv[3])) ? $argv[3] : '');
echo "Finished\n";
echo "The documentation is generated in static folder\n";
break;
Expand Down
9 changes: 5 additions & 4 deletions libs/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
require_once(dirname( __FILE__)."/markdown_extended.php");
$tree = array();
$base = dirname(dirname(__FILE__));
$options = get_options();
$options = get_options(isset($argv[2]) ? $argv[2] : '');
$docs_path = $base . '/' . $options['docs_path'];
$multilanguage = !empty($options['languages']) ? TRUE : FALSE;

// Options
function get_options() {
function get_options($config_file) {
global $base;
$options = array(
'title' => "Documentation",
Expand All @@ -33,7 +33,8 @@ function get_options() {
'template' => 'default'
);
// 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)) {
$config = json_decode(file_get_contents($config_file), true);
$options = array_merge($options, $config);
Expand All @@ -53,6 +54,7 @@ function get_options() {
exit;
}
}
if (!ini_get('date.timezone')) date_default_timezone_set('GMT');
return $options;
}

Expand Down Expand Up @@ -143,7 +145,6 @@ function generate_page($file) {
if (!$file) {
$page['path'] = '';
$page['markdown'] = '';
$page['content'] = '';
$page['title'] = 'Oh No';
$page['content'] = "<h3>Oh No. That page doesn't exist</h3>";
$options['file_editor'] = false;
Expand Down
8 changes: 6 additions & 2 deletions libs/static.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php

// Generate Static Documentation
function generate_static() {
function generate_static($out_dir) {
global $tree, $base, $docs_path, $output_path, $options, $mode, $multilanguage, $output_language;
$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);
build_tree();
if (!$multilanguage) generate_static_branch($tree, '');
Expand Down

0 comments on commit 33b8144

Please sign in to comment.