History

Clean up docs directory and fix links

Jed Fox committed 7 years ago

Commit 73eab0b1 parent 676f4f67 files · +133 −135Browse files

Showing the changes to docs/Filter-Reference.md (1 of 7 files). Show all

Unified · Split

docs/Filter-Reference.md+42−44
@@ -1,13 +1,11 @@
1−---
2−
31 **Table of contents:**
42
5−* [Overview](https://github.com/Thibaut/devdocs/wiki/Filter-Reference#overview)
6−* [Instance methods](https://github.com/Thibaut/devdocs/wiki/Filter-Reference#instance-methods)
7−* [Core filters](https://github.com/Thibaut/devdocs/wiki/Filter-Reference#core-filters)
8−* [Custom filters](https://github.com/Thibaut/devdocs/wiki/Filter-Reference#custom-filters)
9− - [CleanHtmlFilter](https://github.com/Thibaut/devdocs/wiki/Filter-Reference#cleanhtmlfilter)
10− - [EntriesFilter](https://github.com/Thibaut/devdocs/wiki/Filter-Reference#entriesfilter)
3+* [Overview](#overview)
4+* [Instance methods](#instance-methods)
5+* [Core filters](#core-filters)
6+* [Custom filters](#custom-filters)
7+ - [CleanHtmlFilter](#cleanhtmlfilter)
8+ - [EntriesFilter](#entriesfilter)
119
1210 ## Overview
1311
@@ -25,52 +23,52 @@ module Docs · 11 unmodified lines
2523 end
2624 ```
2725
28−Filters which manipulate the Nokogiri node object (`doc` and related methods) are _HTML filters_ and must not manipulate the HTML string (`html`). Vice-versa, filters which manipulate the string representation of the document are _text filters_ and must not manipulate the Nokogiri node object. The two types are divided into two stacks within the scrapers. These stacks are then combined into a pipeline that calls the HTML filters before the text filters (more details [here](https://github.com/Thibaut/devdocs/wiki/Scraper-Reference#filter-stacks)). This is to avoid parsing the document multiple times.
26+Filters which manipulate the Nokogiri node object (`doc` and related methods) are _HTML filters_ and must not manipulate the HTML string (`html`). Vice-versa, filters which manipulate the string representation of the document are _text filters_ and must not manipulate the Nokogiri node object. The two types are divided into two stacks within the scrapers. These stacks are then combined into a pipeline that calls the HTML filters before the text filters (more details [here](./scraper-reference.md#filter-stacks)). This is to avoid parsing the document multiple times.
2927
3028 The `call` method must return either `doc` or `html`, depending on the type of filter.
3129
3230 ## Instance methods
3331
34−* `doc` [Nokogiri::XML::Node]
35− The Nokogiri representation of the container element.
32+* `doc` [Nokogiri::XML::Node]
33+ The Nokogiri representation of the container element.
3634 See [Nokogiri's API docs](http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Node) for the list of available methods.
3735
38−* `html` [String]
36+* `html` [String]
3937 The string representation of the container element.
40−
41−* `context` [Hash] **(frozen)**
38+
39+* `context` [Hash] **(frozen)**
4240 The scraper's `options` along with a few additional keys: `:base_url`, `:root_url`, `:root_page` and `:url`.
4341
44−* `result` [Hash]
45− Used to store the page's metadata and pass back information to the scraper.
42+* `result` [Hash]
43+ Used to store the page's metadata and pass back information to the scraper.
4644 Possible keys:
47−
45+
4846 - `:path` — the page's normalized path
4947 - `:store_path` — the path where the page will be stored (equal to `:path` with `.html` at the end)
5048 - `:internal_urls` — the list of distinct internal URLs found within the page
5149 - `:entries` — the [`Entry`](https://github.com/Thibaut/devdocs/blob/master/lib/docs/core/models/entry.rb) objects to add to the index
5250
53−* `css`, `at_css`, `xpath`, `at_xpath`
51+* `css`, `at_css`, `xpath`, `at_xpath`
5452 Shortcuts for `doc.css`, `doc.xpath`, etc.
5553
56−* `base_url`, `current_url`, `root_url` [Docs::URL]
54+* `base_url`, `current_url`, `root_url` [Docs::URL]
5755 Shortcuts for `context[:base_url]`, `context[:url]`, and `context[:root_url]` respectively.
58−
59−* `root_path` [String]
56+
57+* `root_path` [String]
6058 Shortcut for `context[:root_path]`.
6159
62−* `subpath` [String]
63− The sub-path from the base URL of the current URL.
60+* `subpath` [String]
61+ The sub-path from the base URL of the current URL.
6462 _Example: if `base_url` equals `example.com/docs` and `current_url` equals `example.com/docs/file?raw`, the returned value is `/file`._
6563
66−* `slug` [String]
67− The `subpath` removed of any leading slash or `.html` extension.
64+* `slug` [String]
65+ The `subpath` removed of any leading slash or `.html` extension.
6866 _Example: if `subpath` equals `/dir/file.html`, the returned value is `dir/file`._
6967
70−* `root_page?` [Boolean]
68+* `root_page?` [Boolean]
7169 Returns `true` if the current page is the root page.
7270
73−* `initial_page?` [Boolean]
71+* `initial_page?` [Boolean]
7472 Returns `true` if the current page is the root page or its subpath is one of the scraper's `initial_paths`.
7573
7674 ## Core filters
@@ -148,34 +146,34 @@ The following two models are used under the hood to represent the metadata: · 71 unmodified lines
148146
149147 Each scraper must implement its own `EntriesFilter` by subclassing the [`Docs::EntriesFilter`](https://github.com/Thibaut/devdocs/blob/master/lib/docs/filters/core/entries.rb) class. The base class already implements the `call` method and includes four methods which the subclasses can override:
150148
151−* `get_name` [String]
152− The name of the default entry (aka. the page's name).
153− It is usually guessed from the `slug` (documented above) or by searching the HTML markup.
149+* `get_name` [String]
150+ The name of the default entry (aka. the page's name).
151+ It is usually guessed from the `slug` (documented above) or by searching the HTML markup.
154152 **Default:** modified version of `slug` (underscores are replaced with spaces and forward slashes with dots)
155153
156−* `get_type` [String]
157− The type of the default entry (aka. the page's type).
158− Entries without a type can be searched for but won't be listed in the app's sidebar (unless no other entries have a type).
154+* `get_type` [String]
155+ The type of the default entry (aka. the page's type).
156+ Entries without a type can be searched for but won't be listed in the app's sidebar (unless no other entries have a type).
159157 **Default:** `nil`
160158
161−* `include_default_entry?` [Boolean]
162− Whether to include the default entry.
163− Used when a page consists of multiple entries (returned by `additional_entries`) but doesn't have a name/type of its own, or to remove a page from the index (if it has no additional entries), in which case it won't be copied on the local filesystem and any link to it in the other pages will be broken (as explained on the [Scraper Reference](https://github.com/Thibaut/devdocs/wiki/Scraper-Reference) page, this is used to keep the `:skip` / `:skip_patterns` options to a maintainable size, or if the page includes links that can't reached from anywhere else).
159+* `include_default_entry?` [Boolean]
160+ Whether to include the default entry.
161+ Used when a page consists of multiple entries (returned by `additional_entries`) but doesn't have a name/type of its own, or to remove a page from the index (if it has no additional entries), in which case it won't be copied on the local filesystem and any link to it in the other pages will be broken (as explained on the [Scraper Reference](./scraper-reference.md) page, this is used to keep the `:skip` / `:skip_patterns` options to a maintainable size, or if the page includes links that can't reached from anywhere else).
164162 **Default:** `true`
165163
166−* `additional_entries` [Array]
167− The list of additional entries.
168− Each entry is represented by an Array of three attributes: its name, fragment identifier, and type. The fragment identifier refers to the `id` attribute of the HTML element (usually a heading) that the entry relates to. It is combined with the page's path to become the entry's path. If absent or `nil`, the page's path is used. If the type is absent or `nil`, the default `type` is used.
169− Example: `[ ['One'], ['Two', 'id'], ['Three', nil, 'type'] ]` adds three additional entries, the first one named "One" with the default path and type, the second one named "Two" with the URL fragment "#id" and the default type, and the third one named "Three" with the default path and the type "type".
170− The list is usually constructed by running through the markup. Exceptions can also be hard-coded for specific pages.
164+* `additional_entries` [Array]
165+ The list of additional entries.
166+ Each entry is represented by an Array of three attributes: its name, fragment identifier, and type. The fragment identifier refers to the `id` attribute of the HTML element (usually a heading) that the entry relates to. It is combined with the page's path to become the entry's path. If absent or `nil`, the page's path is used. If the type is absent or `nil`, the default `type` is used.
167+ Example: `[ ['One'], ['Two', 'id'], ['Three', nil, 'type'] ]` adds three additional entries, the first one named "One" with the default path and type, the second one named "Two" with the URL fragment "#id" and the default type, and the third one named "Three" with the default path and the type "type".
168+ The list is usually constructed by running through the markup. Exceptions can also be hard-coded for specific pages.
171169 **Default:** `[]`
172170
173171 The following accessors are also available, but must not be overridden:
174172
175−* `name` [String]
173+* `name` [String]
176174 Memoized version of `get_name` (`nil` for the root page).
177175
178−* `type` [String]
176+* `type` [String]
179177 Memoized version of `get_type` (`nil` for the root page).
180178
181179 **Notes:**
@@ -223,4 +221,4 @@ end · 41 unmodified lines
223221 ```
224222
225223
226−return [[Home]]
224+return [[Home]]