Skip to content

Commit 24f003a

Browse files
committed
v0.4.0: major refactor w/ breaking changes.
1 parent cfe4cb7 commit 24f003a

11 files changed

+662
-418
lines changed

README.md

+52-21
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,44 @@ rc-release-notes
9696
kc-rt-faq Ripple Trade Migration FAQ
9797
```
9898

99-
#### Githubify Mode
99+
#### Building Markdown
100100

101-
This mode runs the preprocessor only, so you can generate Markdown files that are more likely to display properly in conventional Markdown parsers (like the one built into GitHub). Use the `-g` flag followed by a doc page (relative to the configured content dir):
101+
This mode runs the pre-processor only, so you can generate Markdown files that are more likely to display properly in conventional Markdown parsers (like the one built into GitHub). Use the `--md` flag to output Markdown files, skipping the HTML/PDF templates entirely.
102102

103103
```sh
104-
$ dactyl_build -g page_with_dactyl_syntax.md
104+
$ dactyl_build --md
105105
```
106106

107+
In Markdown mode, the `-s` option does not copy static files from the `template_static_path`.
108+
109+
#### Building Only One Page
110+
111+
If you only want to build a single page, you can use the `--only` flag, followed by the filename you want to build (either the input filename ending in `.md` or the output filename ending in `.html`):
112+
113+
```sh
114+
dactyl_build --only index.html --pdf
115+
```
116+
117+
This command can be combined with the `--pdf` or `--md` flags. You can also use it with the `--target` setting (in case you want the context from the target even though you're only building one page.)
118+
119+
#### Watch Mode
120+
121+
You can use the `-w` flag to make Dactyl run continuously, watching for changes to its input templates or markdown files. Whenever it detects that a file has changed, Dactyl automatically rebuilds the output in whatever the current mode is, (HTML, PDF, or Markdown).
122+
123+
To be detected as a change, the file has to match one of the following patterns:
124+
125+
```
126+
*.md
127+
*/code_samples/*
128+
template-*.html
129+
```
130+
131+
Beware: some configurations can lead to an infinite loop. (For example, if your output directory is a subdirectory of your content directory and you use Dactyl in `--md` mode.)
132+
133+
**Limitations:** Watch mode can be combined with `--only`, but re-builds the page even when it detects changes to unrelated pages. Watch mode doesn't detect changes to the config file, static files, or filters.
134+
135+
To stop watching, interrupt the Dactyl process (Ctrl-C in most terminals).
136+
107137
### Link Checking
108138

109139
The link checker is a separate script. It assumes that you've already built some documentation to an output path. Use it as follows:
@@ -182,14 +212,11 @@ targets:
182212
display_name: Ripple Trade Migration FAQ
183213
```
184214

185-
In addition to `name` and `display_name`, a target definition can contain the following fields:
215+
In addition to `name` and `display_name`, a target definition can contain arbitrary key-values to be inherited by all pages in this target. Dictionary values are inherited such that keys that aren't set in the page are carried over from the target, recursively. The rest of the time, fields that appear in a page definition take precedence over fields that appear in a target definition.
216+
217+
Some things you may want to set at the target level include `filters` (an array of filters to apply to pages in this target), `template` (template to use when building HTML), and `pdf_template` (template to use when building PDF). You can also use the custom values in templates and preprocessing. Some filters define additional fields that affect the filter's behavior.
186218

187-
| Field | Type | Description |
188-
|:----------------|:-----------|:----------------------------------------------|
189-
| `filters` | Array | Names of filters to apply to all pages in this target. |
190-
| `image_subs` | Dictionary | Mapping of image paths to replacement paths that should be used when building this target. (Use this, for example, to provide absolute paths to images uploaded to a CDN or CMS.) |
191-
| `image_re_subs` | Dictionary | Same as `image_subs`, but the keys are regular expressions and the patterns can contain backreferences to matched subgroups (e.g. `\\1` for the first parenthetical group). |
192-
| ... | (Various) | Arbitrary key-values to be inherited by all pages in this target. (You can use this for pre-processing or in templates.) The following field names cannot be used: `name`, `display_name`, `image_subs`, `filters`, and `pages`. |
219+
The following field names cannot be inherited: `name`, `display_name`, and `pages`.
193220

194221
### Pages
195222

@@ -203,7 +230,6 @@ pages:
203230
category: References
204231
html: reference-rippleapi.html
205232
md: https://raw.githubusercontent.com/ripple/ripple-lib/0.17.2/docs/index.md
206-
ripple.com: https://ripple.com/build/rippleapi/
207233
filters:
208234
- remove_doctoc
209235
- add_version
@@ -215,7 +241,6 @@ pages:
215241
category: References
216242
html: reference-rippled.html
217243
md: reference-rippled.md
218-
ripple.com: https://ripple.com/build/rippled-apis/
219244
targets:
220245
- local
221246
- ripple.com
@@ -232,7 +257,6 @@ Each individual page definition can have the following fields:
232257
| `category` | String | _(Optional)_ The name of a category to group this page into. This is used by Dactyl's built-in templates to organize the table of contents. |
233258
| `template` | String | _(Optional)_ The filename of a custom [Jinja][] HTML template to use when building this page for HTML, relative to the **template_path** in your config. |
234259
| `pdf_template` | String | _(Optional)_ The filename of a custom [Jinja][] HTML template to use when building this page for PDF, relative to the **template_path** in your config. |
235-
| (Short names of targets) | String | _(Optional)_ If provided, use these values to replace links that would go to this file when building the specified targets. Use this if the page can't be accessed via its normal .html filename in some situations. |
236260
| ... | (Various) | Additional arbitrary key-value pairs as desired. These values can be used by templates or pre-processing. |
237261

238262
[Jinja]: http://jinja.pocoo.org/
@@ -248,8 +272,13 @@ Dactyl pre-processes Markdown files by treating them as [Jinja][] Templates, so
248272
| Field | Value |
249273
|:------------------|:---------------------------------------------------------|
250274
| `target` | The [target](#targets) definition of the current target. |
251-
| `pages` | The [array of page definitions](#pages) in the current target. |
275+
| `pages` | The [array of page definitions](#pages) in the current target. Use this to generate navigation across pages. (The default templates don't do this, but you should.) |
252276
| `currentpage` | The definition of the page currently being rendered. |
277+
| `categories` | A de-duplicated array of categories that are used by at least one page in this target, sorted in the order they first appear. |
278+
| `config` | The global Dactyl config object. |
279+
| `content` | The parsed HTML content of the page currently being rendered. |
280+
| `current_time` | The current date as of rendering. The format is YYYY-MM-DD by default; you can also set the `time_format` field to a custom [stftime format string](http://strftime.org/). |
281+
| `mode` | The output format: either `html` (default), `pdf`, or `md`. |
253282

254283

255284
### Adding Variables from the Commandline
@@ -282,15 +311,14 @@ You cannot set the following reserved keys:
282311

283312
- `name`
284313
- `display_name` (Instead, use the `--title` argument to set the display name of the target on the commandline.)
285-
- `filters`
286-
- `image_subs`
287-
- `image_re_subs`
288314
- `pages`
289315

290316

291317
### Filters
292318

293-
Furthermore, Dactyl supports additional custom post-processing through the use of filters. Filters can operate on the markdown (after it's been pre-processed), on the raw HTML (after it's been parsed), or on a BeautifulSoup object representing the output HTML. Dactyl comes with several filters, which you can enable in your config file. Support for user-defined filters is planned but not yet implemented.
319+
Furthermore, Dactyl supports additional custom post-processing through the use of filters. Filters can operate on the markdown (after it's been pre-processed), on the raw HTML (after it's been parsed), or on a BeautifulSoup object representing the output HTML. Dactyl comes with several filters, which you can enable in your config file.
320+
321+
You can also write your own filters. If you do, you must specify the paths to the folder(s) containing your filter files in the `filter_paths` array of the config file.
294322

295323
See the [examples](examples/) for examples of how to do many of these things.
296324

@@ -303,7 +331,10 @@ Dactyl provides the following information to templates, which you can access wit
303331
| `target` | The [target](#targets) definition of the current target. |
304332
| `pages` | The [array of page definitions](#pages) in the current target. Use this to generate navigation across pages. (The default templates don't do this, but you should.) |
305333
| `currentpage` | The definition of the page currently being rendered. |
306-
| `categories` | An array of categories that are used by at least one page in this target. |
334+
| `categories` | A de-duplicated array of categories that are used by at least one page in this target, sorted in the order they first appear. |
335+
| `config` | The global Dactyl config object. |
307336
| `content` | The parsed HTML content of the page currently being rendered. |
308-
| `current_time` | The current date as of rendering, in the format "Monthname Day, Year" |
309-
| `sidebar_content` | A table of contents generated from the current page's headers. Wrap this in a `<ul>` element. |
337+
| `current_time` | The current date as of rendering. The format is YYYY-MM-DD by default; you can also set the `time_format` field to a custom [stftime format string](http://strftime.org/). |
338+
| `mode` | The output format: either `html` (default), `pdf`, or `md`. |
339+
| `page_toc` | A table of contents generated from the current page's headers. Wrap this in a `<ul>` element. |
340+
| `sidebar_content` | (Deprecated alias for `page_toc`.) |

0 commit comments

Comments
 (0)