Skip to content

Commit b4b51b4

Browse files
authored
Merge pull request #165 from osfameron/tabset-upgrade-reprise
AV-55075 Tabset upgrade
2 parents 99bafcf + 7522659 commit b4b51b4

File tree

10 files changed

+142
-483
lines changed

10 files changed

+142
-483
lines changed

gulp.d/tasks/build-preview-pages.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
'use strict'
22

3-
// NOTE remove patch after upgrading from asciidoctor.js to @asciidoctor/core
4-
Error.call = (self, ...args) => {
5-
const err = new Error(...args)
6-
return Object.assign(self, { message: err.message, stack: err.stack })
7-
}
8-
9-
const asciidoctor = require('asciidoctor.js')()
3+
const Asciidoctor = require('@asciidoctor/core')()
104
const File = require('vinyl')
115
const fs = require('fs-extra')
126
const handlebars = require('handlebars')
@@ -65,7 +59,21 @@ module.exports =
6559
merge(compileLayouts(src), registerPartials(src), registerHelpers(src), copyImages(previewSrc, previewDest))
6660
),
6761
])
68-
.then(([baseUiModel, { layouts }]) => [{ ...baseUiModel, env: process.env }, layouts])
62+
.then(([baseUiModel, { layouts }]) => {
63+
const extensions = ((baseUiModel.asciidoc || {}).extensions || []).map((request) => {
64+
ASCIIDOC_ATTRIBUTES[request.replace(/^@|\.js$/, '').replace(/[/]/g, '-') + '-loaded'] = ''
65+
const extension = require(request)
66+
extension.register.call(Asciidoctor.Extensions)
67+
return extension
68+
})
69+
const asciidoc = { extensions }
70+
for (const component of Object.values(baseUiModel.site.components)) {
71+
for (const version of component.versions || []) version.asciidoc = asciidoc
72+
}
73+
baseUiModel = { ...baseUiModel, env: process.env }
74+
delete baseUiModel.asciidoc
75+
return [baseUiModel, layouts]
76+
})
6977
.then(([baseUiModel, layouts, iconDefs = new Map()]) =>
7078
vfs
7179
.src('**/*.adoc', { base: previewSrc, cwd: previewSrc })
@@ -84,7 +92,7 @@ module.exports =
8492
uiModel.page = { layout: '404', title: 'Page Not Found' }
8593
} else {
8694
const pageModel = (uiModel.page = { ...uiModel.page })
87-
const doc = asciidoctor.load(file.contents, { safe: 'safe', attributes: ASCIIDOC_ATTRIBUTES })
95+
const doc = Asciidoctor.load(file.contents, { safe: 'safe', attributes: ASCIIDOC_ATTRIBUTES })
8896
const attributes = doc.getAttributes()
8997
pageModel.layout = doc.getAttribute('page-layout', 'default')
9098
pageModel.title = doc.getDocumentTitle()
@@ -177,7 +185,6 @@ module.exports =
177185
function loadSampleUiModel (src) {
178186
return fs.readFile(ospath.join(src, 'ui-model.yml'), 'utf8').then((contents) => {
179187
const uiModel = yaml.safeLoad(contents)
180-
uiModel.env = process.env
181188
if (process.env.DEPLOY_PRIME_URL) uiModel.site.url = process.env.DEPLOY_PRIME_URL
182189
Object.entries(uiModel.site.components).forEach(([name, component]) => {
183190
component.name = name

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"@fortawesome/free-regular-svg-icons": "~5.13",
2121
"@fortawesome/free-solid-svg-icons": "~5.13",
2222
"@octokit/rest": "~18.0",
23-
"asciidoctor.js": "1.5.9",
23+
"@asciidoctor/core": "~2.2",
24+
"@asciidoctor/tabs": "1.0.0-beta.3",
2425
"autoprefixer": "~9.8",
2526
"browser-pack-flat": "~3.4",
2627
"browserify": "~16.5",

preview-src/index.adoc

Lines changed: 25 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ From the menu:Couchbase Web Console[Buckets] menu, click the menu:Statistics[] l
2222

2323
.Here is some {sqlpp}
2424
====
25-
[source,sqlpp]
25+
[,sqlpp]
2626
----
2727
SELECT * FROM `travel-sample` WHERE type = "airline" LIMIT 1;
2828
CREATE PRIMARY INDEX ON `users` WITH {"defer_build": true};
@@ -32,7 +32,7 @@ BUILD INDEX ON `users`(`#primary`, `ix_name`, `ix_email`);
3232

3333
.Here is some W3 Extended Backus-Naur Format
3434
====
35-
[source,ebnf]
35+
[,ebnf]
3636
----
3737
index-pair ::= '"' 'indexes' '"' ':' ( 'null'
3838
| '"' index '"'
@@ -60,7 +60,7 @@ Then click the image:arrow-small-down.svg[,16,role=icon]image:arrow-small-up.svg
6060

6161
This section demonstrates the interactive, try it now feature of the docs.
6262

63-
[source.try-it,ruby]
63+
[.try-it,ruby]
6464
----
6565
require 'couchbase'
6666
@@ -79,7 +79,7 @@ rescue Couchbase::Error::DocumentNotFound
7979
end
8080
----
8181

82-
[source.try-it,java]
82+
[.try-it,java]
8383
----
8484
import com.couchbase.client.core.error.DocumentNotFoundException;
8585
import com.couchbase.client.java.*;
@@ -117,82 +117,17 @@ This section provides information on the server resources across the cluster.
117117

118118
Installation will vary based on your operation system.
119119

120-
// NOTE this HTML is generated by the tabs-block extension; never type this in a document directly!
121-
++++
122-
<div class="tabset is-loading">
123-
<div class="ulist tabs">
124-
<ul>
125-
<li>
126-
<p><a id="tabset1_ubuntu"></a>Ubuntu</p>
127-
</li>
128-
<li>
129-
<p><a id="tabset1_red-hat"></a>Red Hat</p>
130-
</li>
131-
<li>
132-
<p><a id="tabset1_debian"></a>Debian</p>
133-
</li>
134-
<li>
135-
<p><a id="tabset1_test1"></a>Test1</p>
136-
</li>
137-
<li>
138-
<p><a id="tabset1_test2"></a>Test2</p>
139-
</li>
140-
<li>
141-
<p><a id="tabset1_test3"></a>Test3</p>
142-
</li>
143-
<li>
144-
<p><a id="tabset1_test4"></a>Test4</p>
145-
</li>
146-
<li>
147-
<p><a id="tabset1_test5"></a>Test5</p>
148-
</li>
149-
</ul>
150-
</div>
151-
<div class="content">
152-
<div class="tab-pane is-active" aria-labelledby="tabset1_ubuntu">
153-
<div class="paragraph">
154-
<p>Content for Ubuntu tab.</p>
155-
</div>
156-
</div>
157-
<div class="tab-pane" aria-labelledby="tabset1_red-hat">
158-
<div class="paragraph">
159-
<p>Content for Red Hat tab.</p>
160-
</div>
161-
</div>
162-
<div class="tab-pane" aria-labelledby="tabset1_debian">
163-
<div class="paragraph">
164-
<p>Content for Debian tab.</p>
165-
</div>
166-
</div>
167-
<div class="tab-pane" aria-labelledby="tabset1_test1">
168-
<div class="paragraph">
169-
<p>Content for test 1 tab.</p>
170-
</div>
171-
</div>
172-
<div class="tab-pane" aria-labelledby="tabset1_test2">
173-
<div class="paragraph">
174-
<p>Content for test 2 tab.</p>
175-
</div>
176-
</div>
177-
<div class="tab-pane" aria-labelledby="tabset1_test3">
178-
<div class="paragraph">
179-
<p>Content for test 3 tab.</p>
180-
</div>
181-
</div>
182-
<div class="tab-pane" aria-labelledby="tabset1_test4">
183-
<div class="paragraph">
184-
<p>Content for test 4 tab.</p>
185-
</div>
186-
</div>
187-
<div class="tab-pane" aria-labelledby="tabset1_test5">
188-
<div class="paragraph">
189-
<p>Content for test 5 tab.</p>
190-
</div>
191-
</div>
192-
</div>
193-
</div>
194-
++++
195-
120+
[tabs]
121+
====
122+
Ubuntu:: Content for Ubuntu tab.
123+
Red Hat:: Content for Red Hat tab.
124+
Debian:: Content for Debian tab.
125+
Test1:: Content for test 1 tab.
126+
Test2:: Content for test 2 tab.
127+
Test3:: Content for test 3 tab.
128+
Test4:: Content for test 4 tab.
129+
Test5:: Content for test 5 tab.
130+
====
196131

197132
== Admonition Blocks
198133

@@ -362,19 +297,19 @@ With the stream-based views, data returned when `stale` is set to `ok` is closer
362297
The *Server Resources* statistics section displays the resource information on this server including swap usage, free RAM, CPU utilization percentage,and FTS RAM used.
363298

364299
.A query using the fluent API (lines are forced to wrap)
365-
[source,java]
300+
[,java]
366301
----
367302
[data-source-url=https://github.com/couchbase/docs-sdk-java/blob/20c44c9e7ca86ea475b7aa33c58d5670aa7c4495/modules/ROOT/pages/n1ql-queries-with-sdk.adoc#L53-L58]
368-
Statement statement = select("fname", "lname", "age").from(i("default")).where(x("age").gt(x("$age"))); // <1>
303+
Statement statement = select("fname", "lname", "age").from(i("default")).where(x("age").gt(x("$age"))); // <.>
369304
JsonObject placeholderValues = JsonObject.create().put("age", 22);
370-
q = N1qlQuery.parameterized(statement, placeholderValues); // <2>
371-
for (N1qlQueryRow row : bkt.query(q)) { // <3>
305+
q = N1qlQuery.parameterized(statement, placeholderValues); // <.>
306+
for (N1qlQueryRow row : bkt.query(q)) { // <.>
372307
System.out.println(row);
373308
}
374309
----
375-
<1> Defines the query.
376-
<2> Inserts placeholder values into the query.
377-
<3> Runs the query.
310+
<.> Defines the query.
311+
<.> Inserts placeholder values into the query.
312+
<.> Runs the query.
378313

379314
[#vbucket-stats]
380315
== Monitoring `vBucket` Resources
@@ -501,7 +436,7 @@ POST http://nodename:8091/settings/viewUpdateDaemon
501436
updateInterval=10000&updateMinChanges=7000
502437
----
503438

504-
[source,json5, role="no-callouts"]
439+
[.no-callouts,json5]
505440
----
506441
{
507442
"_id": "_design/myddoc",
@@ -521,7 +456,7 @@ updateInterval=10000&updateMinChanges=7000
521456
You can set this information when creating and updating design documents through the design document REST API.
522457
To perform this operation using the `curl` tool:
523458

524-
[source,console]
459+
[,console]
525460
----
526461
$ curl -X POST -v -d 'updateInterval=7000&updateMinChanges=7000' \
527462
'http://Administrator:Password@192.168.0.72:8091/settings/viewUpdateDaemon'
@@ -539,7 +474,7 @@ Issues resolved in this release:
539474
* https://issues.couchbase.com/browse/KAFKAC-82[KAFKAC-82]: [FEATURE] Implement log redaction for Kafka Connector
540475
* https://issues.couchbase.com/browse/KAFKAC-90[KAFKAC-90]: [FEATURE] Source: Add config settings to enable compression
541476

542-
[source,xml]
477+
[,xml]
543478
----
544479
<dependency>
545480
<groupId>com.couchbase.client</groupId>

preview-src/ui-model.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,6 @@ page:
173173
content: Liber Recusabo
174174
url: '#'
175175
urlType: 'internal'
176+
asciidoc:
177+
extensions:
178+
- '@asciidoctor/tabs'

0 commit comments

Comments
 (0)