Skip to content

Commit 285b70f

Browse files
authored
Initial commit
0 parents  commit 285b70f

File tree

10 files changed

+296
-0
lines changed

10 files changed

+296
-0
lines changed

.github/CONTRIBUTING.adoc

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
= Contributing to Hazelcast Tutorials
2+
3+
This guide covers how to use this template to contribute to Hazelcast tutorials.
4+
5+
== Repository Structure
6+
7+
All tutorials follow the same structure:
8+
9+
- `.github/workflows/build-site.yml`: A build hook that builds the documentation site when a change is merged.
10+
- `docs/`: Source content in the link:https://docs.antora.org/antora/latest/standard-directories/[standard Antora file and directory structure].
11+
- `create.sh`: A script that converts the Asciidoc files in the `docs/` directory to a PDF. This script requires the link:https://docs.asciidoctor.org/asciidoctor/latest/cli/[Asciidoctor CLI] to be installed.
12+
- `antora-playbook-local.yml`: An Antora playbook that builds the tutorials subsite locally.
13+
- `lib/`: Asciidoc extensions that are needed to generate the tutorials subsite locally.
14+
- `package.json`: Scripts for building the tutorials subsite locally as well as checking links and serving the files.
15+
16+
== Adding a New Tutorial
17+
18+
. Create a new repository, using this link:https://github.com/hazelcast-guides/base-guide[template].
19+
+
20+
TIP: Use a brief name for the new repository as it will be the endpoint of the tutorial when it's published.
21+
22+
. Rename the file in `docs/modules/ROOT/pages` to the name of your repository.
23+
24+
. Add the filename to the template in the README.
25+
26+
. Write your tutorial by following the instructions in the file.
27+
28+
. Submit a pull request against the `develop` branch of the link:https://github.com/hazelcast/hazelcast-docs[`hazelcast-docs` repository] to append your tutorial repository to the `content.sources` field in the `antora-playbook.yml` and `antora-playbook-local.yml` files.
29+
+
30+
For example:
31+
+
32+
```yaml
33+
content:
34+
sources:
35+
- url: https://github.com/hazelcast-guides/<your-repo>
36+
branches: main
37+
start_path: docs
38+
```
39+
+
40+
After the pull request is merged, your tutorial will be available on the documentation site in ~10 minutes.
41+
42+
== Previewing a Tutorial
43+
44+
To preview your content in a local version of the tutorials subsite, do the following:
45+
46+
. Install the required dependencies by running `npm i` at the root of your repository.
47+
48+
. Build the site.
49+
+
50+
```bash
51+
npm run-script build-local
52+
```
53+
+
54+
You should see the following:
55+
+
56+
`Site generation complete!`
57+
58+
. Serve the site locally.
59+
+
60+
```bash
61+
npm run-script serve
62+
```
63+
+
64+
This script automatically copies the local URL to your clipboard.
65+
66+
. In a web browser, paste the URL into the address bar.
67+
68+
You can browse the site for your tutorial, or you can append the name of your tutorial's filename to the end of the URL. For example: http://localhost:3000/tutorials/<your tutorial>.
69+
70+
NOTE: Search does not work locally. The search bar displays results only for tutorials that are already published on docs.hazelcast.com.

.github/workflows/build-site.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This workflow takes the contents of the branches/tags and builds the production documentation site
2+
name: Build production site
3+
4+
on:
5+
push:
6+
branches: [master]
7+
8+
jobs:
9+
dispatch:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Trigger build
13+
run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
target/
2+
.idea/
3+
.settings/
4+
.classpath
5+
.directory
6+
.project
7+
.surefire-*
8+
.DS_Store
9+
*.iml
10+
*.ipr
11+
*.iws
12+
*.txt
13+
node_modules/
14+
local-docs/
15+
package-lock.json

README.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Replace <filename> with the name of your repository, and replace <tutorial name> with the title of the tutorial.
2+
// For guidance on using this template, see .github/CONTRIBUTING.adoc
3+
This repository hosts the documentation and code samples for the link:https://docs.hazelcast.com/tutorials/<filename>[<tutorial name> tutorial].

antora-playbook-local.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
site:
2+
title: Documentation
3+
start_page: tutorials::index.adoc
4+
url: http:localhost:3000
5+
keys:
6+
docsearch_id: 'QK2EAH8GB0'
7+
docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5'
8+
docsearch_index: 'prod_hazelcast_docs'
9+
content:
10+
sources:
11+
- url: https://github.com/hazelcast/hazelcast-docs
12+
branches: main
13+
start_paths: [tutorials, home]
14+
- url: https://github.com/hazelcast-guides/adoc-templates.git
15+
branches: antora-doc
16+
- url: .
17+
branches: master
18+
start_paths: docs
19+
ui:
20+
bundle:
21+
url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip
22+
snapshot: true
23+
asciidoc:
24+
attributes:
25+
page-pagination: true@
26+
# Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/
27+
page-experimental: true
28+
idprefix: ''
29+
idseparator: '-'
30+
extensions:
31+
- ./lib/tabs-block.js

create.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc;
2+
asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc;

docs/antora.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: tutorials
2+
version: ~
3+
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
////
2+
Make sure to rename this file to the name of your repository and add the filename to the README. This filename must not conflict with any existing tutorials.
3+
////
4+
5+
// Describe the title of your article by replacing 'Tutorial template' with the page name you want to publish.
6+
= Tutorial template
7+
// Add required variables
8+
:page-layout: tutorial
9+
:page-product: // Required: Define the product filter for this tutorial. Add one of the following: platform, imdg, cloud, operator
10+
:page-categories: // Optional: Define the categories for this tutorial. Check the current categories on the tutorials homepage (https://docs.hazelcast.com/tutorials/). Add one or more of the existing categories or add new ones as a comma-separated list. Make sure that you use title case for all categories.
11+
:page-lang: java // Optional: Define what Hazelcast client languages are supported by this tutorial. Leave blank or add one or more of: java, go, python, cplus, node, csharp.
12+
:page-enterprise: // Required: Define whether this tutorial requires an Enterprise license (true or blank)
13+
:page-est-time: // Required: Define the estimated number of time required to complete the tutorial in minutes. For example, 10 mins
14+
:description: // Required: Summarize what this tutorial is about in a sentence or two. What you put here is reused as the tutorial's first paragraph and included in HTML description tags. Start the sentence with an action verb such as 'Deploy' or 'Connect'.
15+
16+
{description}
17+
18+
// Give some context about the use case for this tutorial. What will the reader learn?
19+
== Context
20+
21+
// Optional: What does the reader need before starting this tutorial? Think about tools or knowledge. Delete this section if your readers can dive straight into the lesson without requiring any prerequisite knowledge.
22+
== Before you Begin
23+
24+
Before starting this tutorial, make sure that you meet the following prerequisites:
25+
26+
* Prerequisite one
27+
* Prerequisite two
28+
* etc
29+
30+
== Step 1. <Step Title>
31+
32+
////
33+
Introduce what your audience will learn in each step, then continue to write the steps in the tutorial.
34+
You can choose one of these approaches to write your tutorial part:
35+
36+
* In a narrative style if your parts are short or you are using screenshots to do most of the talking.
37+
* In a "Goal > Steps > Outcome" structure to build a predictable flow in all your tutorial parts.
38+
39+
Whatever option you choose when designing your tutorial should be carried through in subsequent parts.
40+
////
41+
42+
== Step 2. <Step Title>
43+
44+
////
45+
Continue the design approach you chose in the previous part and continue it through to the end of the tutorial.
46+
////
47+
48+
== Summary
49+
50+
////
51+
Summarise what knowledge the reader has gained by completing the tutorial, including a summary of each step's goals (this is a good way to validate whether your tutorial has covered all you need it to.)
52+
////
53+
54+
55+
== See Also
56+
57+
// Optionally, add some links to resources, such as other related guides.

lib/tabs-block.js

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* Copyright (c) 2018 OpenDevise, Inc.
2+
*
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6+
7+
/**
8+
* Extends the AsciiDoc syntax to support a tabset. The tabset is created from
9+
* a dlist enclosed in an example block that is marked with the tabs style.
10+
*
11+
* Usage:
12+
*
13+
* [tabs]
14+
* ====
15+
* Tab A::
16+
* +
17+
* --
18+
* Contents of tab A.
19+
* --
20+
* Tab B::
21+
* +
22+
* --
23+
* Contents of tab B.
24+
* --
25+
* ====
26+
*
27+
* @author Dan Allen <[email protected]>
28+
*/
29+
const IdSeparatorCh = '-'
30+
const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g
31+
const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g
32+
const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List')
33+
const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem')
34+
35+
const generateId = (str, idx) =>
36+
`tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}`
37+
38+
function tabsBlock () {
39+
this.onContext('example')
40+
this.process((parent, reader, attrs) => {
41+
const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html)
42+
const tabsetIdx = parent.getDocument().counter('idx-tabset')
43+
const nodes = []
44+
nodes.push(createHtmlFragment('<div class="tabset is-loading">'))
45+
const container = this.parseContent(this.createBlock(parent, 'open'), reader)
46+
const sourceTabs = container.getBlocks()[0]
47+
if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return
48+
const tabs = List.$new(parent, 'ulist')
49+
tabs.addRole('tabs')
50+
const panes = {}
51+
sourceTabs.getItems().forEach(([[title], details]) => {
52+
const tab = ListItem.$new(tabs)
53+
tabs.$append(tab)
54+
const id = generateId(title.getText(), tabsetIdx)
55+
tab.text = `[[${id}]]${title.text}`
56+
let blocks = details.getBlocks()
57+
const numBlocks = blocks.length
58+
if (numBlocks) {
59+
if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks()
60+
panes[id] = blocks.map((block) => (block.parent = parent) && block)
61+
}
62+
})
63+
nodes.push(tabs)
64+
nodes.push(createHtmlFragment('<div class="content">'))
65+
Object.entries(panes).forEach(([id, blocks]) => {
66+
nodes.push(createHtmlFragment(`<div class="tab-pane" aria-labelledby="${id}">`))
67+
nodes.push(...blocks)
68+
nodes.push(createHtmlFragment('</div>'))
69+
})
70+
nodes.push(createHtmlFragment('</div>'))
71+
nodes.push(createHtmlFragment('</div>'))
72+
parent.blocks.push(...nodes)
73+
})
74+
}
75+
76+
function register (registry) {
77+
registry.block('tabs', tabsBlock)
78+
}
79+
80+
module.exports.register = register

package.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "hazelcast-docs-playbook",
3+
"version": "1.0.0",
4+
"description": "Script for working with Hazelcast tutorials locally",
5+
"author": "Jake Cahill",
6+
"license": "ISC",
7+
"scripts": {
8+
"build-local": "antora --to-dir local-docs --fetch --generator @antora/site-generator-default antora-playbook-local.yml",
9+
"check-links-local": "antora --generator @antora/xref-validator antora-playbook-local.yml",
10+
"serve": "serve local-docs",
11+
"expose": "ngrok http 5000"
12+
},
13+
"devDependencies": {
14+
"@antora/cli": "^3.0.0",
15+
"@antora/site-generator-default": "^3.0.0",
16+
"@antora/xref-validator": "gitlab:antora/xref-validator",
17+
"@djencks/antora-aggregate-collector": "^0.1.0-beta.1",
18+
"asciidoctor-kroki": "^0.10.0",
19+
"ngrok": "^4.2.2",
20+
"serve": "^13.0.2"
21+
}
22+
}

0 commit comments

Comments
 (0)