Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
246 commits
Select commit Hold shift + click to select a range
51fe257
Initial commit of empty table of classes
m-hulbert Jun 1, 2022
33919c8
Add descriptions for RestChannel
m-hulbert Jun 1, 2022
2d90ffc
Improve descriptions for RestChannel based on review feedback
m-hulbert Jun 8, 2022
635a297
WIP - Initial commit
tbedford Jun 13, 2022
4038a95
EDX-167 initial commit - WIP
tbedford Jun 13, 2022
4aab2d8
Add more descriptions
tbedford Jun 14, 2022
eca3e8f
Add descriptions for Rest class.
tbedford Jun 14, 2022
e008ac8
[EDX-168] - initial commit
tbedford Jun 15, 2022
995ebd3
Add more descriptions
tbedford Jun 15, 2022
35058b0
Add ChannelStateChange description
tbedford Jun 16, 2022
aff3085
Add ChannelOptions descriptions
tbedford Jun 16, 2022
edda8c6
Add descriptions for Message
tbedford Jun 16, 2022
43f92c3
Add descriptions for batch classes
m-hulbert Jun 21, 2022
5e2113c
Add "Returns" column to tables
tbedford Jun 23, 2022
d99f92d
Add Returns to tables
tbedford Jun 23, 2022
2368e0d
Add Returns to table and missing descriptions.
tbedford Jun 23, 2022
a9cf8a4
Add missing classes and descriptions.
tbedford Jun 23, 2022
876487f
Add description for batch and device
tbedford Jun 23, 2022
bda6b3b
Add Returns to table and missing descriptions.
tbedford Jun 23, 2022
081bd66
Add return values
tbedford Jun 24, 2022
9a5f2e7
Adds returns
tbedford Jun 24, 2022
c748dec
Add more returns
tbedford Jun 24, 2022
4aff307
Add returns
tbedford Jun 24, 2022
fb4394e
Add descriptions to enums.
tbedford Jun 27, 2022
bf450a9
Add channel mode descriptions
tbedford Jun 27, 2022
d9cdc55
Add form factor descriptions and correct spec point
tbedford Jun 27, 2022
43320c6
Delete DevicePushTransportType as no longer in spec.
tbedford Jun 27, 2022
087bc1f
Add Crypto and CipherParams descriptions
tbedford Jun 27, 2022
d89d008
Adds descriptions for JsonObject, ErrorInfo, EventEmitter.
tbedford Jun 28, 2022
b344b07
Update descriptions.md
tbedford Jun 29, 2022
bd22ee2
Update descriptions.md
tbedford Jun 29, 2022
31f8291
Update Crypto class
tbedford Jun 29, 2022
c86ee85
Update table descriptions and layout
tbedford Jun 29, 2022
a8e7b4f
Update batch descriptions for consistency
m-hulbert Jun 29, 2022
a4db4ce
Update descriptions.md
tbedford Jun 30, 2022
b3b8434
Update descriptions.md
tbedford Jun 30, 2022
fe7475c
Merge pull request #8 from ably/edx-172-encryption-stats
tbedford Jun 30, 2022
34f5a46
Create README
tbedford Jun 30, 2022
a6f271c
Add presence class descriptions
m-hulbert Jun 30, 2022
96afadf
Style null with backtick
m-hulbert Jun 30, 2022
a3c8bf6
Merge pull request #6 from ably/edx-169-batch-classes
m-hulbert Jun 30, 2022
915c339
Merge pull request #10 from ably/create-readme
tbedford Jun 30, 2022
ab11f45
Conform to style guide.
tbedford Jun 30, 2022
b7c1426
Update memberKey and correct table alignment and parameter length
m-hulbert Jun 30, 2022
269959f
Update descriptions.md
tbedford Jul 1, 2022
fde8efe
Add BatchSpec description
m-hulbert Jul 1, 2022
ead4086
Add table for SDK implementation tracking
m-hulbert Jul 1, 2022
dee2709
Merge pull request #12 from ably/sdk-implemented
m-hulbert Jul 1, 2022
30d2bc7
Make references to synchronization consistent
m-hulbert Jul 5, 2022
54c237b
Merge pull request #11 from ably/edx-171-presence-classes
m-hulbert Jul 5, 2022
b3e9314
Changes based on feedback
tbedford Jul 5, 2022
d8ac771
merge
tbedford Jul 5, 2022
b9e1110
Updates to conform to spec.
tbedford Jul 5, 2022
6c91a30
Changes based on feedback
tbedford Jul 5, 2022
16d03a5
Merge pull request #2 from ably/edx-166-realtime-rest
tbedford Jul 5, 2022
795a3a8
Add descriptions
tbedford Jul 6, 2022
46eefa9
Update descriptions.
tbedford Jul 6, 2022
916d67c
Update descriptions.md
tbedford Jul 6, 2022
8217477
Update descriptions.md
tbedford Jul 6, 2022
86274d9
Update descriptions.md
tbedford Jul 6, 2022
8676f03
Update descriptions.md
tbedford Jul 6, 2022
a7f88a2
Update descriptions.md
tbedford Jul 6, 2022
55ce577
Fixes
tbedford Jul 6, 2022
12f0419
Merge branch 'edx-173-misc' of https://github.com/ably/canonical-api-…
tbedford Jul 6, 2022
dab4e3f
Remove JsonObject table as not used.
tbedford Jul 6, 2022
11aaca7
Add Event and Data parameters
tbedford Jul 6, 2022
59f567b
Update README.md
tbedford Jul 6, 2022
8cc09be
Apply standardisation to RestChannel
m-hulbert Jul 6, 2022
35caac7
Standardise enum descriptions and tables
m-hulbert Jul 6, 2022
6968090
Update descriptions.md
tbedford Jul 7, 2022
39ae2ce
Update descriptions.md
tbedford Jul 7, 2022
471ccce
Update descriptions.md
tbedford Jul 7, 2022
aea5f6f
Update descriptions.md
tbedford Jul 7, 2022
203ceed
Update descriptions.md
tbedford Jul 7, 2022
0ade44c
Update descriptions.md
tbedford Jul 7, 2022
07e45dd
Address feedback.
tbedford Jul 7, 2022
0ccf994
Remove VCDiffDecoder whilst checking params
m-hulbert Jul 7, 2022
9d6dd32
Remove brackets and update table heading
m-hulbert Jul 7, 2022
9c27c00
Update descriptions.md
tbedford Jul 7, 2022
b3348c7
Merge pull request #7 from ably/edx-174-enum-descriptions
m-hulbert Jul 7, 2022
50e6b42
Update descriptions.md
tbedford Jul 7, 2022
c8c7d38
Update descriptions.md
tbedford Jul 7, 2022
5ac8ab9
Merge pull request #9 from ably/edx-173-misc
tbedford Jul 7, 2022
d93b589
Address feedback
tbedford Jul 8, 2022
663dfb1
Address feedback - 1
tbedford Jul 8, 2022
7163e33
Update descriptions.md
tbedford Jul 8, 2022
c088c57
Update descriptions.md
tbedford Jul 8, 2022
2fd684d
Update descriptions.md
tbedford Jul 8, 2022
a1954c8
Update descriptions.md
tbedford Jul 8, 2022
fc4285b
Update descriptions.md
tbedford Jul 8, 2022
2625926
Update descriptions.md
tbedford Jul 8, 2022
c941ec1
Update descriptions.md
tbedford Jul 8, 2022
e68bb8a
Update descriptions.md
tbedford Jul 8, 2022
74abe07
Update descriptions.md
tbedford Jul 8, 2022
8283acc
Update descriptions.md
tbedford Jul 8, 2022
3b2dbb9
Update descriptions.md
tbedford Jul 8, 2022
a77f12d
Update descriptions.md
tbedford Jul 8, 2022
35f58dc
Make connect() linked
tbedford Jul 8, 2022
2284469
Address feedback -2
tbedford Jul 8, 2022
27f15e9
Address feedback - 3
tbedford Jul 8, 2022
cbcce8b
Address feedback - 4
tbedford Jul 8, 2022
969b8e8
Update descriptions.md
tbedford Jul 8, 2022
47625a2
Merge pull request #4 from ably/edx-168-channel-classes
tbedford Jul 8, 2022
a1bdccb
Fixed based on feedback.
tbedford Jul 11, 2022
5d09801
Update descriptions.md
tbedford Jul 11, 2022
476f436
Update descriptions.md
tbedford Jul 11, 2022
1167960
Update descriptions.md
tbedford Jul 11, 2022
c51c7b9
Merge pull request #3 from ably/edx-167-auth-connection
tbedford Jul 11, 2022
f6d62b4
Correct type in class description
m-hulbert Jul 11, 2022
9c7b3a4
Merge pull request #1 from ably/edx-165-first-class
m-hulbert Jul 11, 2022
edd2c2d
Merge pull request #14 from ably/tbedford-patch-1
m-hulbert Jul 11, 2022
7c45391
Add class descriptions for push
m-hulbert Jul 11, 2022
de3ae38
Add class description for Push
m-hulbert Jul 11, 2022
559ceb2
Fix table alignment for ConnectionState
m-hulbert Jul 11, 2022
02e0599
Merge pull request #15 from ably/m-hulbert-patch-1
tbedford Jul 11, 2022
2c9936e
Add activate and deactivate method descriptions
m-hulbert Jul 11, 2022
c403431
Merge pull request #16 from ably/edx-170-push-classes
tbedford Jul 15, 2022
0043a3d
Change unregister to deregister to unsubscribe
m-hulbert Jul 15, 2022
72d439b
Remove links to manually generated API
m-hulbert Jul 15, 2022
6523c2b
Enforce consistent key-value terminology
m-hulbert Jul 15, 2022
41914d3
Update ChannelMetrics descriptions
m-hulbert Jul 15, 2022
8d04ab4
Style < and > with backticks
m-hulbert Jul 15, 2022
f6b9b4d
Link consistently and make links explicit
m-hulbert Jul 21, 2022
093b2aa
Remove contact us from reference
m-hulbert Jul 21, 2022
db6eadb
Add parameters and return to realtime stats()
m-hulbert Jul 21, 2022
416bbe7
Apply downstream suggested improvements from JS docstrings
m-hulbert Jul 22, 2022
887e130
Make PaginatedResult descriptions consistent
m-hulbert Jul 22, 2022
593d9fe
Make property descriptions consistent
m-hulbert Jul 25, 2022
f357c0e
Make class descriptions consistent
m-hulbert Jul 25, 2022
22e8c5f
Apply conistentcy to RestChannel and RealtimeChannel
m-hulbert Jul 25, 2022
4961c32
LocalDevice should be one word and link to its class
m-hulbert Jul 25, 2022
52cfc5d
Fix missing backticks and column alignment
m-hulbert Jul 26, 2022
2d11672
Clarify params of the request() method
m-hulbert Jul 26, 2022
67d28e0
Update class descriptions based on feedback and fix missing backticks
m-hulbert Jul 26, 2022
0e06cab
Merge pull request #17 from ably/edx-219-consistency-and-updates
m-hulbert Jul 27, 2022
e5ad456
Add descriptions for PushChannelSubscription methods
m-hulbert Jul 27, 2022
96b65bc
Add description for listSubscriptions()
m-hulbert Jul 27, 2022
3b46580
rebase and update IDL changes
StevenAppleby Jul 27, 2022
a437698
IDL update feedback
StevenAppleby Jul 29, 2022
0fbb0dd
IDL update feedback
StevenAppleby Jul 29, 2022
262663e
IDL update feedback
StevenAppleby Jul 29, 2022
eace29f
IDL style updates
StevenAppleby Aug 1, 2022
cb851c4
Merge pull request #18 from ably/edx-180-rebase
Sapples Aug 1, 2022
6865ac8
Clarify optional params in method signatures
m-hulbert Aug 1, 2022
372fd54
Merge pull request #19 from ably/edx-222-push-clarifications
m-hulbert Aug 1, 2022
ab35346
Add array of PresenceAction to subscribe()
m-hulbert Aug 3, 2022
dc34c64
Clarify device() descriptions
m-hulbert Aug 3, 2022
34cbb8d
Clarify request() description and params
m-hulbert Aug 3, 2022
48e2cd2
Clarify clientId restrictions
m-hulbert Aug 4, 2022
d387a7f
Clarify environment and fallback behaviour
m-hulbert Aug 4, 2022
5915cc3
Add notice to deprecated properties
m-hulbert Aug 4, 2022
83c3dfc
Remove mention of console.log
m-hulbert Aug 4, 2022
c880e66
Clarify tls description
m-hulbert Aug 4, 2022
5440d4c
Add parameter entries for fromJson() methods
m-hulbert Aug 4, 2022
348af55
Clarify exists() description
m-hulbert Aug 4, 2022
3eca984
Remove unexplained plugins info
m-hulbert Aug 4, 2022
472b40e
Clarify addRequestIds description
m-hulbert Aug 4, 2022
d9511d1
Remove unncessary unit from fallbackRetryTimeout
m-hulbert Aug 4, 2022
0d49989
Clarify authMethod description
m-hulbert Aug 4, 2022
817f1de
Clarify capability description
m-hulbert Aug 4, 2022
52742d9
Update nonce descriptions
m-hulbert Aug 4, 2022
4295761
Standarise errorReason descriptions
m-hulbert Aug 5, 2022
dfe0a4e
Clarify status() method description
m-hulbert Aug 5, 2022
5ead6ad
Update message persistence description for history() methods
m-hulbert Aug 5, 2022
1ac1435
Fix Stats.ConnectionTypes description
m-hulbert Aug 9, 2022
bfa2ad6
Add further info to intervalId for Stats
m-hulbert Aug 9, 2022
98c2b8a
Correct Message.extras description
m-hulbert Aug 9, 2022
5b53963
Clarify syncComplete
m-hulbert Aug 9, 2022
701d3b4
Correct minor styling issues
m-hulbert Aug 9, 2022
6a1d25a
Update ChannelMode description
m-hulbert Aug 9, 2022
95e960e
Clarify ChannelState descriptions
m-hulbert Aug 9, 2022
d65f70b
Correct cipher optional ? placement
m-hulbert Aug 9, 2022
711f45c
Add default values into descriptions
m-hulbert Aug 9, 2022
5fe4847
Make object references consistent
m-hulbert Aug 9, 2022
1764b33
Clarify times as milliseconds since unix epoch
m-hulbert Aug 9, 2022
cd4693f
Shift column alignment for misplaced properties
m-hulbert Aug 10, 2022
86be5c8
Merge pull request #21 from ably/edx-234-implement-tech-fixes
m-hulbert Aug 10, 2022
2c86404
Delete deprecated intervalGranularity property
m-hulbert Aug 11, 2022
9ca3bf4
Replace logLevel integers with log level names
m-hulbert Aug 11, 2022
e374f88
Explicitly state transportParams takes key-value pairs
m-hulbert Aug 11, 2022
138dbbc
Clarify maxMessageSize descriptions and relation
m-hulbert Aug 11, 2022
617a819
Clarify agents property description
m-hulbert Aug 11, 2022
310cfc3
Make publish() descriptions consistent
m-hulbert Aug 11, 2022
7bd56c7
Clarify timeout descriptions and their differences
m-hulbert Aug 11, 2022
20d1dfb
Add callback info to attach and detach descriptions
m-hulbert Aug 12, 2022
b254c02
Further clarify clientOptions.maxMessageSize
m-hulbert Aug 16, 2022
5ce7ce6
Update README with intro, format and conventions
m-hulbert Aug 16, 2022
f5a47c1
Merge pull request #22 from ably/edx-242-clarify-tech-details
m-hulbert Aug 17, 2022
4dce5a6
Reformat sections for clarity
m-hulbert Aug 17, 2022
0e96bb6
Split sentence around static site block
m-hulbert Aug 17, 2022
6dbaf8c
Merge pull request #23 from ably/edx-218-update-readme
m-hulbert Aug 17, 2022
48c7cf0
Add license and copyright.
QuintinWillison Sep 6, 2022
cf9891c
Merge pull request #24 from ably/license-and-copyright
QuintinWillison Sep 6, 2022
7a9f538
Clarify API reference blurb
m-hulbert Sep 13, 2022
6296da4
Merge pull request #26 from ably/edx-155-blurb-clarifications
m-hulbert Sep 13, 2022
6e5f26c
Update readme to reflect move from incubating/temporary to 'in produc…
QuintinWillison Oct 11, 2022
c89e798
Minor change to docs link
tbedford Oct 13, 2022
9eabd2a
Merge pull request #28 from ably/update-readme
tbedford Oct 14, 2022
7ccac7b
Added missing Emitter#Off('event') method with description
sacOO7 Nov 18, 2022
9ea2f96
Fixed channelState as a part of descriptions document
sacOO7 Nov 19, 2022
7454b38
Updated doc to use Deregisters instead of Removes
sacOO7 Nov 19, 2022
9ed479d
Updated doc for disconnectedRetry timeout
sacOO7 Nov 19, 2022
170f5c6
Refactored withCipherKey description for a constructor taking key as a
sacOO7 Nov 20, 2022
0fa3cab
Simplified implementation for RealtimeChannel exists
sacOO7 Nov 20, 2022
74ad5d0
Removed complicated use of unless, made statements more readable
sacOO7 Nov 20, 2022
7a3f4e9
Refactored documentation for presence enter, update and leave
sacOO7 Nov 20, 2022
1cb6137
Refactored documentation for presence enterClient, updateClient and
sacOO7 Nov 20, 2022
9454927
Fixed channel occupancy description
sacOO7 Nov 20, 2022
40144ca
Merge pull request #29 from ably/fix/emitter-off-event
tbedford Nov 21, 2022
e7bafe9
Add documentation for ClientInformation
lawrence-forooghian Nov 21, 2022
bc8cedd
Add API reference for deriveOptions and getDerived method
mohyour Apr 28, 2023
14cc18e
reword deriveOptions description
mohyour May 10, 2023
f441edc
Document RestClient.request’s `version` param
lawrence-forooghian May 1, 2023
8e9c7c9
Merge pull request #30 from ably/add-ClientInformation-docs
lawrence-forooghian May 10, 2023
f18f65f
Merge pull request #32 from ably/add-description-for-rest-request-ver…
lawrence-forooghian May 10, 2023
2123246
Merge pull request #31 from ably/derive-options-api-reference
mohyour May 11, 2023
aa2fbd5
chore: remove existing batch API descriptions
owenpearson May 4, 2023
41cf4f5
add descriptions for `RestClient.batchPublish`
owenpearson May 4, 2023
f989f2a
add descriptions for `RestClient.batchPresence`
owenpearson May 4, 2023
652ef2f
add descriptions for `Auth.revokeTokens`
owenpearson May 4, 2023
daf58a2
Added docstrings for createRecoveryKey.
maratal Nov 5, 2023
a912f92
Typo fix.
maratal Nov 5, 2023
b31e656
Update descriptions.md
maratal Nov 25, 2023
9cafa7c
Merge pull request #33 from ably/new-batch-apis
lawrence-forooghian Dec 1, 2023
791b50c
Update stats spec points
lawrence-forooghian Dec 1, 2023
93dd91a
Remove stats items removed in spec commit a731d12
lawrence-forooghian Dec 1, 2023
570728b
Add descriptions of stats items added in spec commit a731d12
lawrence-forooghian Dec 1, 2023
5650dd1
Merge pull request #36 from ably/docstrings-for-createRecoveryKey
maratal Dec 1, 2023
af4c267
Merge pull request #37 from ably/untyped-stats
lawrence-forooghian Dec 5, 2023
4a06b46
Add descriptions of whenState methods
lawrence-forooghian Feb 27, 2024
a8fdd42
Remove public mention of ConnectionDetails
lawrence-forooghian Mar 8, 2024
7cc5a28
Fix terminology used to refer to REST API version
lawrence-forooghian Mar 20, 2024
4115924
Added description for the `attachOnSubscribe` (TB4) and updated descr…
maratal Sep 24, 2024
dfa833c
Merge pull request #42 from ably/TB4-attachOnSubscribe
maratal Sep 30, 2024
3c38104
Update PresenceAction descriptions
SimonWoolf Nov 28, 2024
25ec0cd
Merge pull request #39 from ably/remove-ConnectionDetails-mention-fro…
lawrence-forooghian Dec 5, 2024
cfc69c3
Merge pull request #40 from ably/remove-mention-of-major-REST-api-ver…
lawrence-forooghian Dec 5, 2024
50ad5e3
Merge pull request #38 from ably/add-whenState-docs
lawrence-forooghian Dec 5, 2024
cff1ec8
Add new fields for mutable messages
SimonWoolf Nov 28, 2024
0eaaa0e
Merge pull request #44 from ably/mutable-message-fields
SimonWoolf Jan 6, 2025
3bd4c53
Prepare for merge to spec repo
SimonWoolf Jan 6, 2025
1dd7fbd
Merge sdk-api-reference repo into spec repo
SimonWoolf Jan 6, 2025
0d8e199
Make build script build markdown files too
SimonWoolf Jan 6, 2025
8425cf0
Port SDK api docstrings readme to contributing.md
SimonWoolf Jan 6, 2025
8930282
Remove implemented.md
SimonWoolf Jan 6, 2025
64b2746
Switch from redcarpet to kramdown for markdown rendering
SimonWoolf Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,74 @@ Historically, before the above guidance was established - in particular around _
This left us open to the problem that client library references to spec items could end up semantically invalid if that spec point was re-used later.
For example, if `XXX1a` and `XXX1c` exist but `XXX1b` doesn’t because it was removed in the past (prior to this guidance being established), then we should introduce `XXX1d` for the new spec item rather than re-using `XXX1b`.

## SDK API docstrings

The `api-docstrings.md` file is a set of language-agnostic reference API commentaries for SDK developers to use when adding docstring comments to Ably SDKs. For new fields, this file should be modified in the same PR that makes the spec changes for those fields.

Modifications should obey the following conventions:

### Table format

#### Classes

The table for each class contains the following columns:

```
| Method / Property | Parameter | Returns | Spec | Description |
```

* **Method/Property**: The full method signature (code formatted only where necessary, e.g. where it includes `<`, or property name.
* **Parameter**: Each parameter should have its own row and be code formatted.
* **Returns**: The return value should be code formatted and has its own row, after the parameters have been listed.
* **Spec**: The spec point related to the method or property.
* **Description**: The language-agnostic description that will form the docstrings.

#### Enums

The table for each enum contains the following columns:

```markdown
| Enum | Spec | Description |
```

* **Enum**: The name of each value for the enum.
* **Spec**: The spec point related to the enum.
* **Description**: The language-agnostic description that will form the docstrings.

### Conventions

The following conventions should be followed when adding a new method or property to the table:

* Use a verb with an `s` for method descriptions. Common uses are:
* `get` --> `retrieves`
* `subscribe` --> `registers (a listener)`
* `publish` --> `Publishes`
* The expression key-value pairs should be hyphenated.
* Parameters or returns that refer to another class are referred to in terms of objects, for example:
```
A [`Channels`]{@link Channels} object.
```

* Links to other classes/enums are written in the format:
```
[`<text>`]{@link <class>#<property>}
```

For example:
```
[`ClientOptions.logLevel`]{@link ClientOptions#logLevel}`
```
* If a method references its own class, it should just be code formatted, and not link to itself.
* Descriptions can link out to conceptual docs hosted on `ably.com/docs`, but should never link to the API references hosted there.
* A class or object should always be capitalized.
* Methods and parameters should always be lower-case.
* If adding a method/property to separate REST and realtime classes, ensure the descriptions are consistent (where possible).
* When a return value is returned in a paginated list, the description should link to the PaginatedResult class, as well as the class of whatever is returned.
* Items deprecated in the features spec should include the following text at the beginning of the description: `DEPRECATED: this <property/method> is deprecated and will be removed in a future version.`
* Default values should be listed in the description field.
* If a minimum or maximum value exists for a parameter then it should be listed in the description field.
* Time values should be referred to as `milliseconds since the Unix epoch` where applicable.

## Release Process

Use our standard [Release Process](https://github.com/ably/engineering/blob/main/sdk/releases.md#release-process), where:
Expand Down
49 changes: 41 additions & 8 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ gemfile do
source 'https://rubygems.org'
gem 'RedCloth', '~> 4.3.2'
gem 'ruby-handlebars', '~> 0.4.1'
gem 'kramdown', '~> 2.4.0'
end
puts 'Gems installed and loaded.'

SOURCE_PATH = File.expand_path('../../textile', __FILE__)
SOURCE_EXTENSION = '.textile'
TEXTILE_EXTENSION = '.textile'
MARKDOWN_EXTENSION = '.md'
ROOT_SOURCE_NAME = 'index'
TEMPLATE_PATH = File.expand_path('../../templates/docs-textile.html.hbs', __FILE__)
OUTPUT_PATH = File.expand_path('../../output', __FILE__)
Expand Down Expand Up @@ -77,16 +79,19 @@ versions = YAML.load_file(META_PATH)['versions']
handlebars = Handlebars::Handlebars.new
template = handlebars.compile(File.read(TEMPLATE_PATH))

source_file_names = Dir.children(SOURCE_PATH).select {
|file_name| file_name.end_with? "#{SOURCE_EXTENSION}"
textile_file_names = Dir.children(SOURCE_PATH).select {
|file_name| file_name.end_with? "#{TEXTILE_EXTENSION}"
}.sort

# File names without '.textile' extension, and without the root 'index'.
plain_file_names = source_file_names.collect {
|file_name| file_name.delete_suffix(SOURCE_EXTENSION)
markdown_file_names = Dir.children(SOURCE_PATH).select {
|file_name| file_name.end_with? "#{MARKDOWN_EXTENSION}"
}.sort

plain_file_names = (textile_file_names + markdown_file_names).collect {
|file_name| file_name.delete_suffix(TEXTILE_EXTENSION).delete_suffix(MARKDOWN_EXTENSION)
} - [ROOT_SOURCE_NAME]

source_file_names.each do |file_name|
textile_file_names.each do |file_name|
print "#{file_name} ... "

# We could possibly have used the Handlebars gem we're using elsewhere for this, however it was barfing on features.textile for no clear reason.
Expand All @@ -96,7 +101,35 @@ source_file_names.each do |file_name|
.gsub(/\{\{\s*PROTOCOL_VERSION\s*\}\}/, versions['protocol'].to_s)

bodyHtml = RedCloth.new(textile, [:no_span_caps]).to_html(*REDCLOTH_RULES)
plain_file_name = file_name.delete_suffix(SOURCE_EXTENSION)
plain_file_name = file_name.delete_suffix(TEXTILE_EXTENSION)
is_root = (plain_file_name == ROOT_SOURCE_NAME)
html = template.call({
bodyContent: bodyHtml,
title: plain_file_name.capitalize(),
file_names: plain_file_names - [plain_file_name],
root_path: is_root ? '' : '../',
copyright: COPYRIGHT,
build_context_title: BUILD_CONTEXT_TITLE,
build_context_url: BUILD_CONTEXT_URL,
build_context_sha: BUILD_CONTEXT_SHA,
})
folder_path = is_root ? OUTPUT_PATH : File.join(OUTPUT_PATH, plain_file_name)
if !is_root
Dir.mkdir folder_path
end
File.write(File.join(folder_path, "index.html"), html)
puts "✓"
end

markdown_file_names.each do |file_name|
print "#{file_name} ... "

markdown_content = remove_frontmatter(File.read(File.join(SOURCE_PATH, file_name)))
.gsub(/\{\{\s*SPECIFICATION_VERSION\s*\}\}/, versions['specification'].to_s)
.gsub(/\{\{\s*PROTOCOL_VERSION\s*\}\}/, versions['protocol'].to_s)

bodyHtml = Kramdown::Document.new(markdown_content).to_html
plain_file_name = file_name.delete_suffix(MARKDOWN_EXTENSION)
is_root = (plain_file_name == ROOT_SOURCE_NAME)
html = template.call({
bodyContent: bodyHtml,
Expand Down
Loading