From fffbb0d6557731ce22beae402ff107a0fdca6e03 Mon Sep 17 00:00:00 2001 From: Neil Dewhurst Date: Fri, 2 Feb 2024 09:51:50 +0000 Subject: [PATCH 01/14] Convert label--* roles to labels --- preview-src/docs-roles.adoc | 100 +++++++++++++++++--- src/css/labels.css | 49 ++++++++++ src/js/60-docs-roles.js | 176 ++++++++++++++++++++++++++++++++---- src/partials/article.hbs | 11 +-- 4 files changed, 296 insertions(+), 40 deletions(-) diff --git a/preview-src/docs-roles.adoc b/preview-src/docs-roles.adoc index 6cc4b4e0..e675d0f4 100644 --- a/preview-src/docs-roles.adoc +++ b/preview-src/docs-roles.adoc @@ -1,5 +1,5 @@ = Docs `code test` flags -:page-role: not-on-aura +:page-role: not-on-aura new-5.17 :page-theme: docs // :page-labels: fabric enterprise-edition alpha test @@ -8,9 +8,81 @@ Flags sections as Not Available on Aura, Aura DB Enterprise, Enterprise Edition, Fabric, and Deprecated -- -Blocks with the appropriate roles have text appended. +[role="label--new-5.17 label--enterprise-edition"] +== Relationship property type constraints -[role=not-on-aura] +Blocks with the appropriate roles have labels added. + +[role=label--new-5.17] +Lorem ipsum dolor sit amet, consectetur adipiscing elit. +Mauris eget leo nunc, nec tempus mi? Curabitur id nisl mi, ut vulputate urna. +Quisque porta facilisis tortor, vitae bibendum velit fringilla vitae! Lorem ipsum dolor sit amet, consectetur adipiscing elit. + +This is a normal paragraph. + +[role=label--deprecated-5.17] +Lorem ipsum dolor sit amet, consectetur adipiscing elit. + +[role=label--enterprise-edition] +Lorem ipsum dolor sit amet, consectetur adipiscing elit. +Mauris eget leo nunc, nec tempus mi? Curabitur id nisl mi, ut vulputate urna. + +[role=label--deprecated-5.17] +. list with label +. item 2 +. item 3 + +These labels from roles should be used for block elements only. +For inline elements, use a label. + + +=== Code + +Intro para + +[role=label--deprecated-5.17] +.Title +[source, shell] +---- +How does a label look on a code block? +---- + + +=== Examples + +Intro para + +[role=label--new-5.17] +.This is a short one +[example] +==== +Lorem Ipsunm +==== + + +=== Tables + +Intro para + +[[procedure_db_create_setVectorProperty]] +[role=label--admin-only label--deprecated-5.9] +.db.create.setVectorProperty() +[cols="<15s,<85"] +|=== +| Description +a| +Set a vector property on a given node in a more space efficient representation than Cypher’s link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/set#set-set-a-property[`SET`]. +| Signature +m| db.create.setVectorProperty(node :: NODE, key :: STRING, vector :: LIST) :: (node :: NODE) +| Mode +m|WRITE +| Replaced by +a|xref:reference/procedures.adoc#procedure_db_create_setNodeVectorProperty[`db.create.setNodeVectorProperty()`] +|=== + + + +[role=label--not-on-aura] == Not on `code test` Aura Lorem ipsum dolor `code test` sit @@ -38,13 +110,13 @@ And so does this table |=== -[role=aura-db-enterprise] +[role=label--aura-db-enterprise] == AuraDB Enterprise Lorem ipsum dolor sit -[role=aura-db-enterprise not-on-aura] +[role=label--aura-db-enterprise label--not-on-aura] == H2 AuraDB Enterprise AND Not on Aura Lorem ipsum dolor sit @@ -55,23 +127,23 @@ Lorem ipsum dolor sit Lorem ipsum dolor sit -[role=aura-db-enterprise not-on-aura] +[role=label--aura-db-enterprise label--not-on-aura] === H3 AuraDB Enterprise AND Not on Aura Lorem ipsum dolor sit -[role=aura-db-enterprise not-on-aura] +[role=label--aura-db-enterprise label--not-on-aura] === H4 show roles Lorem ipsum dolor sit -[role=fabric] +[role=label--fabric] == Fabric Heading Lorem ipsum -[role=enterprise-edition] +[role=label--enterprise-edition] == Enterprise Edition content Lorem ipsum @@ -82,7 +154,7 @@ Lorem ipsum ==== H4 inside labeled section -[role=deprecated] +[role=label--deprecated] == Deprecated content Other blocks can have deprecated roles added. @@ -96,13 +168,13 @@ This is a second paragraph in the example. This is the third. ==== -[role=deprecated] +[role=label--deprecated] .Example 2 title ==== Example 2 content - this example is deprecated ==== -[role=alpha] +[role=label--alpha] == Alpha content @@ -116,7 +188,7 @@ For more information on algorithm tiers, see <>. Lorem ipsum -[role=beta] +[role=label--beta] == Beta content @@ -131,7 +203,7 @@ For more information on algorithm tiers, see <>. Lorem ipsum -[role=deprecated] +[role=label--deprecated] == Deprecated content Lorem ipsum diff --git a/src/css/labels.css b/src/css/labels.css index 36c5e7ee..a80c265c 100644 --- a/src/css/labels.css +++ b/src/css/labels.css @@ -1,3 +1,52 @@ +.flex-labels-container { + display: flex; + justify-content: space-between; +} + +.header-label { + float: inline-end; + line-height: var(--doc-line-height); + margin-left: 0.2rem; + margin-top: 0.2rem; +} + +.doc > .sect-header h1.page:first-child:has(> .header-label) { + margin-right: 0; +} + +h1 > .header-label { + margin-top: 1.2rem; +} + +.listing-block .content-labels, +.example-block .content-labels { + margin-bottom: 0.2rem; +} + +.content-labels { + margin-bottom:0.2rem; +} + +.has-label { + padding-left: 0.4rem; + border-left: 2px solid rgba(var(--colors-baltic-60)); +} + +.has-label:has(> .content--new) { + border-left-color: var(--success-color); +} + +.has-label:has(> .content--deprecated) { + border-left-color: var(--deprecated-color); +} + +h2 > .flex-label { + float: inline-end; + line-height: var(--doc-line-height); + margin-left: 0.2rem; + margin-top: 0.2rem; +} + .label { display: inline-block; padding: 0.2rem 0.8rem; diff --git a/src/js/60-docs-roles.js b/src/js/60-docs-roles.js index 23973b21..514186ad 100644 --- a/src/js/60-docs-roles.js +++ b/src/js/60-docs-roles.js @@ -1,27 +1,171 @@ import { createElement } from './modules/dom' document.addEventListener('DOMContentLoaded', function () { - const sectionDivs = document.querySelectorAll('body.docs:not(.docshome) div[class^="sect"]:not(.sectionbody,.sect-header)') - sectionDivs.forEach(function (sectionDiv) { - var roles = sectionDiv.classList + + // // legacy roles on headers + // const sectionDivs = document.querySelectorAll('body.docs:not(.docshome) div[class^="sect"]:not(.sectionbody,.sect-header)') + + // sectionDivs.forEach(function (sectionDiv) { + // var roles = sectionDiv.classList + // roles = [...roles].sort().filter(function (c) { + // return (!(c.startsWith('sect') || c === 'display')) + // }) + + // if (roles.length === 0) return + + // var newRolesDiv = createElement('div', 'sect-header') + // var head = sectionDiv.querySelector('h2,h3,h4,h5,h6') + + // if (roles.length > 0) { + // newRolesDiv.append(head) + // var insert = createElement('div', 'roles') + // roles.forEach(function (role) { + // insert.append(createElement('span', `label inline-label ${role}`)) + // }) + // newRolesDiv.append(insert) + // sectionDiv.prepend(newRolesDiv) + // sectionDiv.classList.add('show-roles') + // } + // }) + + + // new styles - convert all roles everywhere to a label + // add a role starting with label-- to any elament + // display a label right-aligned to headings and table captions + // display a label left-aligned to everything else + // ignore inline labels + + + const headings = ['H2','H3','H4','H5','H6','CAPTION'] + + const roleDivs = document.querySelectorAll('body.docs:not(.docshome) *[class*="label--"]') + + const tableDivs = document.querySelectorAll('body.docs:not(.docshome) table[class*="label--"]') + + + // console.log('---') + + // handle different div Classs + // eg headings the role is on the parent div + + + const labelClassMapping = { + "new": "introduced", + } + + const labelTextMapping = { + "enterprise-edition": "Enterprise Edition", + "aura-db-enterprise": "Aura DB Enterprise", + "not-on-aura": "Not available on Aura", + "fabric": "Fabric", + "alpha": "Alpha", + "beta": "Beta", + 'apoc-core': 'APOC Core', + 'apoc-full': 'APOC Full', + 'na': 'N / A', + 'warning': 'Warning!', + 'danger': 'Danger!', + 'mac-os': 'Mac OS', + 'cluster-member-core': 'CORE', + 'cluster-member-read-replica': 'READ_REPLICA', + 'cluster-member-single': 'SINGLE' + } + + var getLabelText = function (role) { + + // label will be eg new-5.19, enterprise-edition, not-on-aura + var label = role.replace('label--','') + var labelParts = label.split('-') + var labelDetails = {} + + if (labelTextMapping[label] !== undefined) { + labelDetails.text = labelTextMapping[label] + labelDetails.class = label + return labelDetails + } + + labelDetails.class = labelParts[0] + + // figure out label text + labelParts[0] = labelClassMapping[labelParts[0]] || labelParts[0] + labelParts = labelParts.map(text => text.substr(0, 1).toUpperCase() + text.substr(1)) + + // if second part is a number, insert 'in' before it + if (!isNaN(labelParts[1])) labelParts.splice(1, 0, 'in') + + labelDetails.text = labelParts.join(' ') + + return labelDetails + } + + + + roleDivs.forEach(function (roleDiv) { + + // ignore spans because they're inline + // we only care about labels on block elements + // DIV or TABLE + if (roleDiv.nodeName === 'SPAN' ) return + + var roles = roleDiv.classList roles = [...roles].sort().filter(function (c) { - return (!(c.startsWith('sect') || c === 'display')) + return (c.startsWith('label--')) }) if (roles.length === 0) return - var newRolesDiv = createElement('div', 'sect-header') - var head = sectionDiv.querySelector('h2,h3,h4,h5,h6') - - if (roles.length > 0) { - newRolesDiv.append(head) - var insert = createElement('div', 'roles') - roles.forEach(function (role) { - insert.append(createElement('span', `role ${role}`)) - }) - newRolesDiv.append(insert) - sectionDiv.prepend(newRolesDiv) - sectionDiv.classList.add('show-roles') + // console.log(roles) + + let labels = [] + + // var newRolesDiv = createElement('div', 'flex-labels') + + roles.forEach(function (role) { + + // construct label name and text + const labelDetails = getLabelText(role) + + // create a span element for the label + const labelDiv = createElement('span', `label content-label label--${labelDetails.class}`) + labelDiv.appendChild(document.createTextNode(labelDetails.text)) + + // remove the role from the parent div + roleDiv.classList.remove(role) + + labels.push(labelDiv) + + }) + + + + if (headings.includes(roleDiv.firstElementChild.nodeName) || roleDiv.nodeName === 'H1') { + var labelsDiv + if (roleDiv.nodeName === 'H1') { + labelsDiv = roleDiv + } else { + labelsDiv = roleDiv.firstElementChild + } + for (const label of labels) { + label.classList.add('header-label') + labelsDiv.append(label) + } } + + else { + var newRolesDiv = createElement('div', 'content-labels') + // add the span to the parent div + for (const label of labels) { + newRolesDiv.append(label) + } + const contentLabel = Array.from(labels[0].classList).find(c => c.startsWith('label--')).replace('label--','') + roleDiv.firstElementChild.classList.add('labeled', `content--${contentLabel}`) + roleDiv.prepend(newRolesDiv) + roleDiv.classList.add('has-label') + } + }) + + + + }) diff --git a/src/partials/article.hbs b/src/partials/article.hbs index 56948f0c..045f62f9 100644 --- a/src/partials/article.hbs +++ b/src/partials/article.hbs @@ -10,16 +10,7 @@ If you typed the URL of this page manually, please double check that you entered {{else}}
-{{#with page.title}} -

{{{this}}}

-{{/with}} -{{#with (or page.attributes.role page.role)}} -
- {{#each (split-string this ' ')}} - - {{/each}} -
-{{/with}} +

{{{ page.title }}}

{{#with (or page.attributes.labels page.labels)}} From 537f3db90c924228154f04f1c79a0b91cdd53e97 Mon Sep 17 00:00:00 2001 From: Neil Dewhurst Date: Fri, 2 Feb 2024 09:52:10 +0000 Subject: [PATCH 02/14] Linted --- src/css/labels.css | 2 +- src/js/60-docs-roles.js | 80 +++++++++++++++-------------------------- 2 files changed, 29 insertions(+), 53 deletions(-) diff --git a/src/css/labels.css b/src/css/labels.css index a80c265c..d338d4b2 100644 --- a/src/css/labels.css +++ b/src/css/labels.css @@ -24,7 +24,7 @@ h1 > .header-label { } .content-labels { - margin-bottom:0.2rem; + margin-bottom: 0.2rem; } .has-label { diff --git a/src/js/60-docs-roles.js b/src/js/60-docs-roles.js index 514186ad..743c3f51 100644 --- a/src/js/60-docs-roles.js +++ b/src/js/60-docs-roles.js @@ -1,10 +1,9 @@ import { createElement } from './modules/dom' document.addEventListener('DOMContentLoaded', function () { - // // legacy roles on headers // const sectionDivs = document.querySelectorAll('body.docs:not(.docshome) div[class^="sect"]:not(.sectionbody,.sect-header)') - + // sectionDivs.forEach(function (sectionDiv) { // var roles = sectionDiv.classList // roles = [...roles].sort().filter(function (c) { @@ -28,53 +27,44 @@ document.addEventListener('DOMContentLoaded', function () { // } // }) - // new styles - convert all roles everywhere to a label // add a role starting with label-- to any elament // display a label right-aligned to headings and table captions // display a label left-aligned to everything else // ignore inline labels - - const headings = ['H2','H3','H4','H5','H6','CAPTION'] + const headings = ['H2', 'H3', 'H4', 'H5', 'H6', 'CAPTION'] const roleDivs = document.querySelectorAll('body.docs:not(.docshome) *[class*="label--"]') - const tableDivs = document.querySelectorAll('body.docs:not(.docshome) table[class*="label--"]') - - - // console.log('---') - - // handle different div Classs + // handle different div Classs // eg headings the role is on the parent div - const labelClassMapping = { - "new": "introduced", + new: 'introduced', } const labelTextMapping = { - "enterprise-edition": "Enterprise Edition", - "aura-db-enterprise": "Aura DB Enterprise", - "not-on-aura": "Not available on Aura", - "fabric": "Fabric", - "alpha": "Alpha", - "beta": "Beta", + 'enterprise-edition': 'Enterprise Edition', + 'aura-db-enterprise': 'Aura DB Enterprise', + 'not-on-aura': 'Not available on Aura', + fabric: 'Fabric', + alpha: 'Alpha', + beta: 'Beta', 'apoc-core': 'APOC Core', 'apoc-full': 'APOC Full', - 'na': 'N / A', - 'warning': 'Warning!', - 'danger': 'Danger!', + na: 'N / A', + warning: 'Warning!', + danger: 'Danger!', 'mac-os': 'Mac OS', 'cluster-member-core': 'CORE', 'cluster-member-read-replica': 'READ_REPLICA', - 'cluster-member-single': 'SINGLE' + 'cluster-member-single': 'SINGLE', } var getLabelText = function (role) { - // label will be eg new-5.19, enterprise-edition, not-on-aura - var label = role.replace('label--','') + var label = role.replace('label--', '') var labelParts = label.split('-') var labelDetails = {} @@ -83,29 +73,26 @@ document.addEventListener('DOMContentLoaded', function () { labelDetails.class = label return labelDetails } - + labelDetails.class = labelParts[0] - + // figure out label text - labelParts[0] = labelClassMapping[labelParts[0]] || labelParts[0] - labelParts = labelParts.map(text => text.substr(0, 1).toUpperCase() + text.substr(1)) - + labelParts[0] = labelClassMapping[labelParts[0]] || labelParts[0] + labelParts = labelParts.map((text) => text.substr(0, 1).toUpperCase() + text.substr(1)) + // if second part is a number, insert 'in' before it - if (!isNaN(labelParts[1])) labelParts.splice(1, 0, 'in') - + if (!isNaN(labelParts[1])) labelParts.splice(1, 0, 'in') + labelDetails.text = labelParts.join(' ') return labelDetails } - - roleDivs.forEach(function (roleDiv) { - // ignore spans because they're inline // we only care about labels on block elements // DIV or TABLE - if (roleDiv.nodeName === 'SPAN' ) return + if (roleDiv.nodeName === 'SPAN') return var roles = roleDiv.classList roles = [...roles].sort().filter(function (c) { @@ -116,15 +103,14 @@ document.addEventListener('DOMContentLoaded', function () { // console.log(roles) - let labels = [] + const labels = [] // var newRolesDiv = createElement('div', 'flex-labels') roles.forEach(function (role) { - // construct label name and text const labelDetails = getLabelText(role) - + // create a span element for the label const labelDiv = createElement('span', `label content-label label--${labelDetails.class}`) labelDiv.appendChild(document.createTextNode(labelDetails.text)) @@ -133,15 +119,12 @@ document.addEventListener('DOMContentLoaded', function () { roleDiv.classList.remove(role) labels.push(labelDiv) - }) - - if (headings.includes(roleDiv.firstElementChild.nodeName) || roleDiv.nodeName === 'H1') { var labelsDiv if (roleDiv.nodeName === 'H1') { - labelsDiv = roleDiv + labelsDiv = roleDiv } else { labelsDiv = roleDiv.firstElementChild } @@ -149,23 +132,16 @@ document.addEventListener('DOMContentLoaded', function () { label.classList.add('header-label') labelsDiv.append(label) } - } - - else { + } else { var newRolesDiv = createElement('div', 'content-labels') // add the span to the parent div for (const label of labels) { newRolesDiv.append(label) } - const contentLabel = Array.from(labels[0].classList).find(c => c.startsWith('label--')).replace('label--','') + const contentLabel = Array.from(labels[0].classList).find((c) => c.startsWith('label--')).replace('label--', '') roleDiv.firstElementChild.classList.add('labeled', `content--${contentLabel}`) roleDiv.prepend(newRolesDiv) roleDiv.classList.add('has-label') } - }) - - - - }) From 3a6d283c90decc973e8f8ec3c1862118295be40f Mon Sep 17 00:00:00 2001 From: Neil Dewhurst Date: Fri, 9 Feb 2024 15:02:02 +0000 Subject: [PATCH 03/14] Read roles from json, align wrapped labels --- gulp.d/tasks/rollup.js | 2 + package-lock.json | 135 +++++++++++++++++++++--- package.json | 1 + preview-src/docs-roles.adoc | 19 +++- src/css/doc.css | 6 +- src/css/labels.css | 123 +++++++++++++--------- src/js/60-docs-roles.js | 189 ++++++++++++++++----------------- src/js/data/rolesData.json | 204 ++++++++++++++++++++++++++++++++++++ 8 files changed, 510 insertions(+), 169 deletions(-) create mode 100644 src/js/data/rolesData.json diff --git a/gulp.d/tasks/rollup.js b/gulp.d/tasks/rollup.js index 28659968..8f4a5210 100644 --- a/gulp.d/tasks/rollup.js +++ b/gulp.d/tasks/rollup.js @@ -5,6 +5,7 @@ const rollupPluginNodeResolve = require('@rollup/plugin-node-resolve').nodeResol const rollupPluginCommonJS = require('@rollup/plugin-commonjs') const rollupPluginBabel = require('@rollup/plugin-babel').babel const rollupPluginTerser = require('rollup-plugin-terser').terser +const rollupPluginJSON = require('@rollup/plugin-json') const toCamel = (s) => { return s.replace(/([-_][a-z])/ig, ($1) => { @@ -35,6 +36,7 @@ async function bundle (vinylFile) { babelHelpers: 'bundled', }), rollupPluginTerser(), + rollupPluginJSON(), ], onwarn: (warning) => { if (warning.code === 'CIRCULAR_DEPENDENCY' && ignoredCircular.some((d) => warning.importer.includes(d))) { diff --git a/package-lock.json b/package-lock.json index 7d71e5e7..a0f6194b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,13 +11,14 @@ "dependencies": { "@antora/cli": "^2.3.3", "@antora/site-generator-default": "^2.3.3", - "@neo4j-ndl/base": "^0.8.3", + "@neo4j-ndl/base": "^2.0.0", "font-awesome": "^4.7.0" }, "devDependencies": { "@gram-data/gram-d3": "^0.1.2", "@rollup/plugin-babel": "^5.2.3", "@rollup/plugin-commonjs": "^17.1.0", + "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^11.1.1", "asciidoctor.js": "1.5.9", "auth0-js": "^9.14.0", @@ -45,7 +46,7 @@ "gulp-vinyl-zip": "~2.2", "handlebars": "~4.7", "highlight.js": "^10.7", - "highlightjs-cypher": "^1.1", + "highlightjs-cypher": "^1.2", "husky": "^4.3.0", "js-yaml": "~3.13", "medium-zoom": "^1.0.6", @@ -1021,9 +1022,9 @@ } }, "node_modules/@neo4j-ndl/base": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/@neo4j-ndl/base/-/base-0.8.3.tgz", - "integrity": "sha512-GwWAtPkzB7R3nIIDq5s05ct1VXAjncrv2Z6NhwiSRQe6e7iSHddVqlFAoWw6VIffXWPKzKlzZ1ebxRSfm38Gkw==" + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@neo4j-ndl/base/-/base-2.4.0.tgz", + "integrity": "sha512-LopFYglm7g5hESh0zSdEjzBg1hAGpb5V7T6omkhno2V+PimT+qr2IO9Knyg2/XH33HBcmJN9aVFdpEG4ibkPiw==" }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.3", @@ -1165,6 +1166,72 @@ "sourcemap-codec": "^1.4.4" } }, + "node_modules/@rollup/plugin-json": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.1.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-json/node_modules/@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-json/node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, + "node_modules/@rollup/plugin-json/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, + "node_modules/@rollup/plugin-json/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@rollup/plugin-node-resolve": { "version": "11.1.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.1.1.tgz", @@ -7725,9 +7792,9 @@ } }, "node_modules/highlightjs-cypher": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/highlightjs-cypher/-/highlightjs-cypher-1.1.5.tgz", - "integrity": "sha512-CKHH2UwydrmXrUEv8m+URq80Mn3BdH81XG0azamJoN7ehHyy713o2W8jkIKIV18/toI4L5xiVBRgTplH6kWdfQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/highlightjs-cypher/-/highlightjs-cypher-1.2.0.tgz", + "integrity": "sha512-mOY/g6R1MgXiYx07icl8nwtXCRDSy4Y9EAlDZKia8Thqe766v6cjnrD6/xWak9UXoLQfWqbHhmRmYuw0SiO+CA==", "dev": true, "dependencies": { "minimist": ">=1.2.6", @@ -18316,9 +18383,9 @@ } }, "@neo4j-ndl/base": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/@neo4j-ndl/base/-/base-0.8.3.tgz", - "integrity": "sha512-GwWAtPkzB7R3nIIDq5s05ct1VXAjncrv2Z6NhwiSRQe6e7iSHddVqlFAoWw6VIffXWPKzKlzZ1ebxRSfm38Gkw==" + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@neo4j-ndl/base/-/base-2.4.0.tgz", + "integrity": "sha512-LopFYglm7g5hESh0zSdEjzBg1hAGpb5V7T6omkhno2V+PimT+qr2IO9Knyg2/XH33HBcmJN9aVFdpEG4ibkPiw==" }, "@nodelib/fs.scandir": { "version": "2.1.3", @@ -18430,6 +18497,46 @@ } } }, + "@rollup/plugin-json": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.1.0" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + }, + "@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, + "estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + } + } + }, "@rollup/plugin-node-resolve": { "version": "11.1.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.1.1.tgz", @@ -23934,9 +24041,9 @@ "dev": true }, "highlightjs-cypher": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/highlightjs-cypher/-/highlightjs-cypher-1.1.5.tgz", - "integrity": "sha512-CKHH2UwydrmXrUEv8m+URq80Mn3BdH81XG0azamJoN7ehHyy713o2W8jkIKIV18/toI4L5xiVBRgTplH6kWdfQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/highlightjs-cypher/-/highlightjs-cypher-1.2.0.tgz", + "integrity": "sha512-mOY/g6R1MgXiYx07icl8nwtXCRDSy4Y9EAlDZKia8Thqe766v6cjnrD6/xWak9UXoLQfWqbHhmRmYuw0SiO+CA==", "dev": true, "requires": { "minimist": ">=1.2.6", diff --git a/package.json b/package.json index 711d68fc..e147d466 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@gram-data/gram-d3": "^0.1.2", "@rollup/plugin-babel": "^5.2.3", "@rollup/plugin-commonjs": "^17.1.0", + "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^11.1.1", "asciidoctor.js": "1.5.9", "auth0-js": "^9.14.0", diff --git a/preview-src/docs-roles.adoc b/preview-src/docs-roles.adoc index e675d0f4..e2e799b9 100644 --- a/preview-src/docs-roles.adoc +++ b/preview-src/docs-roles.adoc @@ -1,4 +1,4 @@ -= Docs `code test` flags += Docs roles with a long title :page-role: not-on-aura new-5.17 :page-theme: docs // :page-labels: fabric enterprise-edition alpha test @@ -8,19 +8,34 @@ Flags sections as Not Available on Aura, Aura DB Enterprise, Enterprise Edition, Fabric, and Deprecated -- + [role="label--new-5.17 label--enterprise-edition"] == Relationship property type constraints Blocks with the appropriate roles have labels added. + +[role=label--aura-db-enterprise label--not-on-aura] +=== H3 AuraDB Enterprise AND Not on Aura + +Lorem ipsum dolor sit + +Open blocks can be used to mark multiple paragraphs within a section. + [role=label--new-5.17] +-- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eget leo nunc, nec tempus mi? Curabitur id nisl mi, ut vulputate urna. + Quisque porta facilisis tortor, vitae bibendum velit fringilla vitae! Lorem ipsum dolor sit amet, consectetur adipiscing elit. +-- + This is a normal paragraph. -[role=label--deprecated-5.17] +The next paragraph has a label, but it's not one we support. + +[role=label--invented-label] Lorem ipsum dolor sit amet, consectetur adipiscing elit. [role=label--enterprise-edition] diff --git a/src/css/doc.css b/src/css/doc.css index fb30eac7..4705b2c9 100644 --- a/src/css/doc.css +++ b/src/css/doc.css @@ -68,7 +68,7 @@ body { .doc h4 code, .doc h5 code, .doc h6 code { - padding: 0.125em 0.25em; + padding: 0 0.25em; background: var(--code-background); } @@ -664,6 +664,10 @@ body { text-align: left; } +.doc .tableblock caption { + display: table-caption; +} + .hide-table-captions .doc .tableblock caption { position: absolute; left: -10000px; diff --git a/src/css/labels.css b/src/css/labels.css index d338d4b2..ec02270e 100644 --- a/src/css/labels.css +++ b/src/css/labels.css @@ -1,16 +1,29 @@ .flex-labels-container { display: flex; justify-content: space-between; + align-items: flex-start; + flex-direction: row-reverse; } -.header-label { - float: inline-end; +.header-label-container { + display: flex; + flex-wrap: wrap; +} + +.header-label-container > div.labels { + display: flex; + align-self: center; + justify-content: space-between; + gap: 0.25rem; + margin-left: auto; line-height: var(--doc-line-height); - margin-left: 0.2rem; - margin-top: 0.2rem; } -.doc > .sect-header h1.page:first-child:has(> .header-label) { +.header-label-container > div.labels.wrapped { + margin-left: 0; +} + +.doc > .sect-header > h1.page:first-child:has(> .labels) { margin-right: 0; } @@ -18,6 +31,14 @@ h1 > .header-label { margin-top: 1.2rem; } +.header-label-container > .header-label:first-of-type { + margin-left: auto; +} + +.doc .tableblock caption > .labels { + float: inline-end; +} + .listing-block .content-labels, .example-block .content-labels { margin-bottom: 0.2rem; @@ -32,11 +53,11 @@ h1 > .header-label { border-left: 2px solid rgba(var(--colors-baltic-60)); } -.has-label:has(> .content--new) { +.has-label:has(> .labels > .label--new) { border-left-color: var(--success-color); } -.has-label:has(> .content--deprecated) { +.has-label:has(> .labels > .label--deprecated) { border-left-color: var(--deprecated-color); } @@ -62,126 +83,126 @@ h2 > .flex-label { margin-top: 0.2rem; } -.label--core, -.label--apoc-core { +span.label--core, +span.label--apoc-core { background: rgba(var(--colors-baltic-20)); color: rgba(var(--colors-baltic-70)); } -.label--full, -.label--apoc-full { +span.label--full, +span.label--apoc-full { background: rgba(var(--colors-forest-15)); color: rgba(var(--colors-forest-50)); } -.label--procedure { +span.label--procedure { background: var(--color-indigo-200); color: var(--color-indigo-700); } -.label--function { +span.label--function { background: rgba(var(--colors-lavender-15)); color: rgba(var(--colors-lavender-50)); } -.label--current { +span.label--current { background: rgba(var(--colors-baltic-50)); color: rgba(var(--colors-baltic-10)); } -.label--free, -.label--beginner { +span.label--free, +span.label--beginner { background: var(--colors-blueberry-70); color: var(--color-white); } -.label--not-on-aura { +span.label--not-on-aura { background: var(--warning-color); color: var(--warning-background-color); } -.label--aura-db-enterprise { +span.label--aura-db-enterprise { background: rgba(var(--colors-baltic-50)); color: rgba(var(--colors-baltic-10)); } -.label--aura, -.label--enterprise-only, -.label--professional, -.label--enterprise, -.label--enterprise-edition { +span.label--aura, +span.label--enterprise-only, +span.label--professional, +span.label--enterprise, +span.label--enterprise-edition { background: rgba(var(--colors-baltic-50)); color: rgba(var(--colors-baltic-10)); } -.label--default, -.label--recommended { +span.label--default, +span.label--recommended { background: rgba(var(--theme-light-palette-primary-bg-strong)); color: rgba(var(--theme-light-palette-primary-bg-weak)); } -.label--added, -.label--changed, -.label--new, -.label--renamed, -.label--updated, -.label--yes { +span.label--added, +span.label--changed, +span.label--new, +span.label--renamed, +span.label--updated, +span.label--yes { background: var(--success-color); color: var(--success-background-color); } -.label--alpha, -.label--beta { +span.label--alpha, +span.label--beta { background: var(--alpha-beta-background-color); color: var(--alpha-beta-color); } -.label--na, -.label--no, -.label--removed { +span.label--na, +span.label--no, +span.label--removed { background: var(--warning-color); color: var(--warning-background-color); } -.label--admin-only, -.label--danger, -.label--warning { +span.label--admin-only, +span.label--danger, +span.label--warning { background: var(--warning-color); color: var(--warning-background-color); } -.label--deprecated, -.label--discontinued { +span.label--deprecated, +span.label--discontinued { background: var(--deprecated-color); color: var(--deprecated-background-color); } -.label--unix, -.label--mac-os, -.label--linux, -.label--windows { +span.label--unix, +span.label--mac-os, +span.label--linux, +span.label--windows { background: rgba(var(--colors-baltic-70)); color: rgba(var(--colors-neutral-10)); } -.label--syntax, -.label--functionality, -.label--cypher { +span.label--syntax, +span.label--functionality, +span.label--cypher { background: var(--code-background); color: var(--code-font-color); } -.label--cluster-member-core { +span.label--cluster-member-core { background: rgba(var(--colors-baltic-15)); color: rgba(var(--colors-baltic-50)); } -.label--cluster-member-read-replica { +span.label--cluster-member-read-replica { background: rgba(var(--colors-forest-15)); color: rgba(var(--colors-forest-50)); } -.label--cluster-member-single { +span.label--cluster-member-single { background: rgba(var(--colors-lemon-10)); background: rgba(var(--colors-lemon-60)); } diff --git a/src/js/60-docs-roles.js b/src/js/60-docs-roles.js index 743c3f51..8189e7c7 100644 --- a/src/js/60-docs-roles.js +++ b/src/js/60-docs-roles.js @@ -1,93 +1,66 @@ import { createElement } from './modules/dom' - -document.addEventListener('DOMContentLoaded', function () { - // // legacy roles on headers - // const sectionDivs = document.querySelectorAll('body.docs:not(.docshome) div[class^="sect"]:not(.sectionbody,.sect-header)') - - // sectionDivs.forEach(function (sectionDiv) { - // var roles = sectionDiv.classList - // roles = [...roles].sort().filter(function (c) { - // return (!(c.startsWith('sect') || c === 'display')) - // }) - - // if (roles.length === 0) return - - // var newRolesDiv = createElement('div', 'sect-header') - // var head = sectionDiv.querySelector('h2,h3,h4,h5,h6') - - // if (roles.length > 0) { - // newRolesDiv.append(head) - // var insert = createElement('div', 'roles') - // roles.forEach(function (role) { - // insert.append(createElement('span', `label inline-label ${role}`)) - // }) - // newRolesDiv.append(insert) - // sectionDiv.prepend(newRolesDiv) - // sectionDiv.classList.add('show-roles') - // } - // }) - - // new styles - convert all roles everywhere to a label - // add a role starting with label-- to any elament - // display a label right-aligned to headings and table captions - // display a label left-aligned to everything else - // ignore inline labels - - const headings = ['H2', 'H3', 'H4', 'H5', 'H6', 'CAPTION'] - - const roleDivs = document.querySelectorAll('body.docs:not(.docshome) *[class*="label--"]') - - // handle different div Classs - // eg headings the role is on the parent div - - const labelClassMapping = { - new: 'introduced', +import rolesData from './data/rolesData.json' + +function checkWrapped () { + const labelContainers = document.querySelectorAll('body.docs:not(.docshome) .header-label-container') + for (const container of labelContainers) { + var child = container.querySelector('.labels') + var lineHeight = parseInt(window.getComputedStyle(container).lineHeight, 10) + if (child.offsetTop - container.offsetTop >= lineHeight) { + child.classList.add('wrapped') + } else { + child.classList.remove('wrapped') + } } +} - const labelTextMapping = { - 'enterprise-edition': 'Enterprise Edition', - 'aura-db-enterprise': 'Aura DB Enterprise', - 'not-on-aura': 'Not available on Aura', - fabric: 'Fabric', - alpha: 'Alpha', - beta: 'Beta', - 'apoc-core': 'APOC Core', - 'apoc-full': 'APOC Full', - na: 'N / A', - warning: 'Warning!', - danger: 'Danger!', - 'mac-os': 'Mac OS', - 'cluster-member-core': 'CORE', - 'cluster-member-read-replica': 'READ_REPLICA', - 'cluster-member-single': 'SINGLE', +document.addEventListener('DOMContentLoaded', function () { + var camelCased = function (str) { + return str.split(/-|\./) + .map((text) => text.substr(0, 1).toUpperCase() + text.substr(1)) + .join('') } - var getLabelText = function (role) { - // label will be eg new-5.19, enterprise-edition, not-on-aura + var getLabelDetails = function (role) { var label = role.replace('label--', '') var labelParts = label.split('-') - var labelDetails = {} - - if (labelTextMapping[label] !== undefined) { - labelDetails.text = labelTextMapping[label] - labelDetails.class = label - return labelDetails - } - labelDetails.class = labelParts[0] + // label could be eg label--new-5.19 but in rolesData it's just new + label = rolesData[labelParts[0]] ? labelParts[0] : label - // figure out label text - labelParts[0] = labelClassMapping[labelParts[0]] || labelParts[0] - labelParts = labelParts.map((text) => text.substr(0, 1).toUpperCase() + text.substr(1)) + if (!rolesData[label]) { + return + } - // if second part is a number, insert 'in' before it - if (!isNaN(labelParts[1])) labelParts.splice(1, 0, 'in') + var labelDetails = { + class: label, + role: label, + text: rolesData[label].displayText || '', + data: { + labelCategory: rolesData[label].labelCategory || '', + product: rolesData[label].product || '', + function: rolesData[label].function || '', + }, + } - labelDetails.text = labelParts.join(' ') + // get version number for version labels + if (rolesData[label].labelCategory === 'version' && labelParts[1]) { + labelDetails.data.version = labelParts[1] + labelDetails.text += ' in ' + labelDetails.data.version + } return labelDetails } + // convert all label-- roles everywhere to a label + // display a label right-aligned to headings and table captions + // wrap to the left on headings when not enough space for labels + // display a label left-aligned to everything else + // ignore inline labels + + const headings = ['H2', 'H3', 'H4', 'H5', 'H6', 'CAPTION'] + const roleDivs = document.querySelectorAll('body.docs:not(.docshome) *[class*="label--"]') + roleDivs.forEach(function (roleDiv) { // ignore spans because they're inline // we only care about labels on block elements @@ -101,47 +74,61 @@ document.addEventListener('DOMContentLoaded', function () { if (roles.length === 0) return - // console.log(roles) - const labels = [] - // var newRolesDiv = createElement('div', 'flex-labels') - roles.forEach(function (role) { - // construct label name and text - const labelDetails = getLabelText(role) + const labelDetails = getLabelDetails(role) + if (typeof labelDetails === 'undefined') { + return + } // create a span element for the label - const labelDiv = createElement('span', `label content-label label--${labelDetails.class}`) - labelDiv.appendChild(document.createTextNode(labelDetails.text)) + const labelSpan = createElement('span', `label content-label label--${labelDetails.class}`) + + // add dataset to the label + if (labelDetails.data.version) labelSpan.dataset.version = labelDetails.data.version + if (labelDetails.data.product !== '') labelSpan.dataset.product = labelDetails.data.product + if (labelDetails.data.function !== '') labelSpan.dataset.function = labelDetails.data.function + + labelSpan.appendChild(document.createTextNode(labelDetails.text)) // remove the role from the parent div roleDiv.classList.remove(role) - labels.push(labelDiv) + labels.push(labelSpan) }) - if (headings.includes(roleDiv.firstElementChild.nodeName) || roleDiv.nodeName === 'H1') { - var labelsDiv - if (roleDiv.nodeName === 'H1') { - labelsDiv = roleDiv - } else { - labelsDiv = roleDiv.firstElementChild - } - for (const label of labels) { + // we only generate labels from defined roles + // no need to do anything if we found only undefined roles + if (labels.length === 0) return + + const labelsLocation = (roleDiv.firstElementChild && headings.includes(roleDiv.firstElementChild.nodeName)) ? roleDiv.firstElementChild : roleDiv + const labelsDiv = createElement('div', 'labels') + + for (const label of labels) { + if (roleDiv.nodeName === 'H1' || headings.includes(roleDiv.firstElementChild.nodeName)) { label.classList.add('header-label') - labelsDiv.append(label) } + labelsDiv.append(label) + const contentLabel = Array.from(label.classList).find((c) => c.startsWith('label--')).replace('label--', '') + roleDiv.dataset[camelCased(contentLabel)] = contentLabel + } + + if (roleDiv.nodeName === 'H1' || headings.includes(roleDiv.firstElementChild.nodeName)) { + labelsLocation.append(labelsDiv) + labelsLocation.classList.add('header-label-container') } else { - var newRolesDiv = createElement('div', 'content-labels') - // add the span to the parent div - for (const label of labels) { - newRolesDiv.append(label) - } - const contentLabel = Array.from(labels[0].classList).find((c) => c.startsWith('label--')).replace('label--', '') - roleDiv.firstElementChild.classList.add('labeled', `content--${contentLabel}`) - roleDiv.prepend(newRolesDiv) + labelsLocation.prepend(labelsDiv) roleDiv.classList.add('has-label') } }) + + // check whether div containing header labels has wrapped onto new line + // if it has wrapped, we left-align the div + checkWrapped() +}) + +// when the window is resized, check whether labels have wrapped or unwrapped +window.addEventListener('resize', function () { + checkWrapped() }) diff --git a/src/js/data/rolesData.json b/src/js/data/rolesData.json new file mode 100644 index 00000000..176257f3 --- /dev/null +++ b/src/js/data/rolesData.json @@ -0,0 +1,204 @@ +{ + "enterprise":{ + "description": "Function available in Enterprise Edition only", + "labelCategory": "product", + "product": "Enterprise Edition", + "displayText": "Enterprise Edition" + }, + "enterprise-edition":{ + "description": "Function available in Enterprise Edition only", + "labelCategory": "product", + "product": "Enterprise Edition", + "displayText": "Enterprise Edition" + }, + "enterprise-only":{ + "description": "Function available in Enterprise Edition only", + "labelCategory": "product", + "product": "Enterprise Edition", + "displayText": "Enterprise Only" + }, + "free":{ + "description": "Function available in Free version only", + "labelCategory": "product", + "product": "AuraDB Free", + "displayText": "Free" + }, + "full":{ + "description": "Function available in Enterprise Edition only", + "labelCategory": "product", + "product": "Enterprise Edition", + "displayText": "Full" + }, + "professional":{ + "description": "Function or feature is available on AuraDB Professional", + "labelCategory": "product", + "product": "AuraDB Professional", + "displayText": "Only available on AuraDB Professional" + }, + "aura-db-enterprise":{ + "description": "Function available in AuraDB Enterprise", + "labelCategory": "product", + "product": "AuraDB Enterprise", + "displayText": "AuraDB Enterprise" + }, + "not-on-aura":{ + "description": "Function or feature is not available on Aura", + "labelCategory": "product", + "product": "Aura", + "displayText": "Not available on Aura" + }, + "aura":{ + "description": "Function or feature is available on Aura", + "labelCategory": "product", + "product": "Aura", + "displayText": "Available on Aura" + }, + "aura-only":{ + "description": "Function or feature is available on Aura only", + "labelCategory": "product", + "product": "Aura", + "displayText": "Only available on Aura" + }, + "new":{ + "description": "The feature or function was added in the version stated", + "labelCategory": "version", + "displayText": "Introduced", + "altDisplayText": "Added" + }, + "added":{ + "description": "The feature or function was added in the version stated", + "labelCategory": "version", + "displayText": "Introduced", + "altDisplayText": "Added" + }, + "changed":{ + "description": "The feature or function was changed in the version stated", + "labelCategory": "version", + "displayText": "Changed" + }, + "default":{ + "description": "The value shown is the default value", + "labelCategory": "function", + "displayText": "Default" + }, + "discontinued":{ + "description": "The feature is no longer available", + "labelCategory": "version", + "displayText": "Discontinued" + }, + "alpha":{ + "labelCategory": "version", + "displayText": "Alpha" + }, + "beta":{ + "labelCategory": "version", + "displayText": "Beta" + }, + "deprecated":{ + "labelCategory": "version", + "displayText": "Deprecated" + }, + "removed":{ + "labelCategory": "version", + "displayText": "Removed" + }, + "renamed":{ + "labelCategory": "version", + "displayText": "Renamed" + }, + "updated":{ + "description": "The feature or function was updated in the version stated", + "labelCategory": "version", + "displayText": "Updated" + }, + "fabric":{ + "labelCategory": "function", + "function": "Fabric", + "displayText": "Fabric" + }, + "apoc-core":{ + "labelCategory": "function", + "displayText": "APOC Core" + }, + "apoc-full":{ + "labelCategory": "function", + "displayText": "APOC Full" + }, + "recommended":{ + "labelCategory": "admonition", + "displayText": "Recommended" + }, + "danger":{ + "labelCategory": "admonition", + "displayText": "Danger" + }, + "warning":{ + "labelCategory": "admonition", + "displayText": "Warning" + }, + "information":{ + "labelCategory": "admonition", + "displayText": "Information" + }, + "yes":{ + "labelCategory": "admonition", + "displayText": "Yes" + }, + "no":{ + "labelCategory": "admonition", + "displayText": "No" + }, + "admin-only": { + "labelCategory": "function", + "displayText": "Admin Only" + }, + "function":{ + "labelCategory": "function", + "displayText": "Function" + }, + "procedure":{ + "labelCategory": "procedure", + "displayText": "Procedure" + }, + "syntax":{ + "labelCategory": "function", + "displayText": "Syntax" + }, + "beginner":{ + "labelCategory": "persona", + "displayText": "Beginner" + }, + "linux":{ + "labelCategory": "environment", + "displayText": "Linux" + }, + "unix":{ + "labelCategory": "environment", + "displayText": "Unix" + }, + "mac-os":{ + "labelCategory": "environment", + "displayText": "Mac OS" + }, + "windows":{ + "labelCategory": "environment", + "displayText": "Windows" + }, + "cluster-member-core":{ + "labelCategory": "function", + "displayText": "CORE" + }, + "cluster-member-read-replica":{ + "labelCategory": "function", + "displayText": "READ_REPLICA" + }, + "cluster-member-single":{ + "labelCategory": "function", + "displayText": "SINGLE" + }, + "na":{ + "labelCategory": "admonition", + "displayText": "N/A" + } + +} \ No newline at end of file From 328d6081aeae738aae5d104bd1b551d22bf7b9f2 Mon Sep 17 00:00:00 2001 From: Neil Dewhurst Date: Tue, 5 Mar 2024 18:42:31 +0000 Subject: [PATCH 04/14] Fix vertical alignment in h1 --- src/css/doc.css | 4 ++++ src/css/labels.css | 1 + 2 files changed, 5 insertions(+) diff --git a/src/css/doc.css b/src/css/doc.css index 4705b2c9..5a30b5ef 100644 --- a/src/css/doc.css +++ b/src/css/doc.css @@ -146,6 +146,10 @@ body { font-weight: 600; } + .doc .header-label-container > div.labels { + padding-top: 0; + } + .doc h2:not(.discrete) { font-size: 1.2rem; } diff --git a/src/css/labels.css b/src/css/labels.css index ec02270e..b75ba422 100644 --- a/src/css/labels.css +++ b/src/css/labels.css @@ -16,6 +16,7 @@ justify-content: space-between; gap: 0.25rem; margin-left: auto; + padding-top: 0.4rem; line-height: var(--doc-line-height); } From cf417acd09adbf7b663ad1e4279118093e8a6e85 Mon Sep 17 00:00:00 2001 From: Nicola Vitucci Date: Fri, 9 Feb 2024 15:54:28 +0000 Subject: [PATCH 05/14] Update style for bibliography sections (#212) The default style for `[bibliography]` sections includes bullet points and padding. This change removes both. --- preview-src/bibliography.adoc | 12 ++++++++++++ preview-src/ui-model.yml | 3 +++ src/css/neo4j-docs.css | 5 +++++ 3 files changed, 20 insertions(+) create mode 100644 preview-src/bibliography.adoc diff --git a/preview-src/bibliography.adoc b/preview-src/bibliography.adoc new file mode 100644 index 00000000..8a2b9a88 --- /dev/null +++ b/preview-src/bibliography.adoc @@ -0,0 +1,12 @@ += Use of `bibliography` + +Citations with xreftext: <>, <>. + +Citations without xreftext (ID only): <>. + +[bibliography] +== References + +* [[[Brandes2001, 1]]] Brandes, Ulrik. "A faster algorithm for betweenness centrality." _Journal of mathematical sociology_ 25, no. 2 (2001): 163-177. link:https://snap.stanford.edu/class/cs224w-readings/brandes01centrality.pdf[]. +* [[[Brandes2007, 2]]] Brandes, Ulrik, and Christian Pich. "Centrality estimation in large networks." _International Journal of Bifurcation and Chaos_ 17, no. 07 (2007): 2303-2318. link:https://www.uni-konstanz.de/mmsp/pubsys/publishedFiles/BrPi07.pdf[]. +* [[[Freeman1977]]] Freeman, Linton C. "A set of measures of centrality based on betweenness." _Sociometry_ (1977): 35-41. diff --git a/preview-src/ui-model.yml b/preview-src/ui-model.yml index 8041a596..c3c1d5be 100644 --- a/preview-src/ui-model.yml +++ b/preview-src/ui-model.yml @@ -208,6 +208,9 @@ page: - content: Algorithms url: algorithms.html urlType: internal + - content: Bibliography + url: bibliography.html + urlType: internal - content: Private Page url: private-page.html urlType: internal diff --git a/src/css/neo4j-docs.css b/src/css/neo4j-docs.css index 38054c6e..2ff85fe4 100644 --- a/src/css/neo4j-docs.css +++ b/src/css/neo4j-docs.css @@ -417,3 +417,8 @@ div.beta-symbol p::before { background-color: var(--warning-background-color); color: var(--warning-color); } + +ul.bibliography { + list-style-type: none; + padding-left: 0; +} From eacb57b91d236337c54394cac59b0ab26435b68b Mon Sep 17 00:00:00 2001 From: Stefano Ottolenghi Date: Fri, 9 Feb 2024 17:28:09 +0100 Subject: [PATCH 06/14] Clarify behavior for `` by making cursor pointer. --- src/css/doc.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/css/doc.css b/src/css/doc.css index 5a30b5ef..01e20b0d 100644 --- a/src/css/doc.css +++ b/src/css/doc.css @@ -1299,6 +1299,10 @@ body { margin-bottom: 1.5rem; } +.doc details summary { + cursor: pointer; +} + .doc details[open] summary { font-weight: bold; } From b58e39f09ea46e7f609b6d03b851667897885bae Mon Sep 17 00:00:00 2001 From: Stefano Ottolenghi Date: Mon, 12 Feb 2024 10:37:32 +0100 Subject: [PATCH 07/14] Fix line highlighting not working on last line of code blocks. --- src/js/vendor/highlight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/vendor/highlight.js b/src/js/vendor/highlight.js index bee0fdff..d9599693 100644 --- a/src/js/vendor/highlight.js +++ b/src/js/vendor/highlight.js @@ -133,7 +133,7 @@ // eat away line breaks or they would be doubled by the div hljs.addPlugin({ 'after:highlightElement': ({ el, result, text }) => { - result.value = result.value.replaceAll(/^(\s*)(.+?)\s*.*?\bmark-line\b.*?<\/span>\n/mg, '
$1$2
') + result.value = result.value.replaceAll(/^(\s*)(.+?)\s*.*?\bmark-line\b.*?<\/span>\n?/mg, '
$1$2
') } }); })() From 7685fcde1e280ac327cdec288abcb35f2254392d Mon Sep 17 00:00:00 2001 From: Nicola Vitucci Date: Thu, 15 Feb 2024 09:54:50 +0000 Subject: [PATCH 08/14] Remove pipe from replaced characters in callouts (#213) --- src/js/06-code.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/06-code.js b/src/js/06-code.js index b43e5a40..9e4e0557 100644 --- a/src/js/06-code.js +++ b/src/js/06-code.js @@ -36,7 +36,7 @@ import { createElement } from './modules/dom' })() var cleanCallouts = function (code) { - return code.replace(/[ |\t]+\n/g, '\n').trimEnd() + return code.replace(/[ \t]+\n/g, '\n').trimEnd() } document.addEventListener('DOMContentLoaded', function () { From 02acfa1dc136d40acf345f17aeca9a724c1a1d3f Mon Sep 17 00:00:00 2001 From: Neil Dewhurst Date: Wed, 28 Feb 2024 11:52:27 +0000 Subject: [PATCH 09/14] switch tabs when id and hash is used (#215) When an ID is set on a block that is part of a tabbed group the tab switching and scroll happens as it does when a user clicks on a tab. --- preview-src/drivers-tabs.adoc | 3 +++ src/js/08-tabs-block.js | 19 +++++++++++++++++++ src/js/12-fragment-jumper.js | 8 ++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/preview-src/drivers-tabs.adoc b/preview-src/drivers-tabs.adoc index 6fcf18eb..fde7e09b 100644 --- a/preview-src/drivers-tabs.adoc +++ b/preview-src/drivers-tabs.adoc @@ -8,10 +8,12 @@ GDS also uses tabs, but they have a different list of tab separators. Rather tha [.tabbed-example] ==== [.include-with-macos] +[[mac-os-bit]] ====== Tab for macOS ====== [.include-with-linux] +[[linux-bit]] ====== Tab for Linux ====== @@ -105,6 +107,7 @@ Note that this requires that Go modules are enabled. ====== [.include-with-java] +[[java-bit]] ====== To use the Java driver, it is recommended employing a dependency manager, such as Maven or Gradle. diff --git a/src/js/08-tabs-block.js b/src/js/08-tabs-block.js index 5cbf5d34..252167e6 100644 --- a/src/js/08-tabs-block.js +++ b/src/js/08-tabs-block.js @@ -205,4 +205,23 @@ document.addEventListener('DOMContentLoaded', function () { parent.removeChild(originalTab) }) + + // + // Make active tab based on url hash + // + function decodeFragment (hash) { + return hash && (~hash.indexOf('%') ? decodeURIComponent(hash) : hash).slice(1) + } + + var fragment, target, scrollTo + if ((fragment = decodeFragment(window.location.hash)) && (target = document.getElementById(fragment))) { + const langSelection = target.getAttribute('data-lang') + const tabbed = target.closest('.tabbed') + scrollTo = tabbed.querySelector(`[data-lang=${langSelection}]`) + if (scrollTo) { + switchTab({ + target: scrollTo, + }) + } + } }) diff --git a/src/js/12-fragment-jumper.js b/src/js/12-fragment-jumper.js index b2021ca8..b11a1e2d 100644 --- a/src/js/12-fragment-jumper.js +++ b/src/js/12-fragment-jumper.js @@ -24,14 +24,18 @@ e.preventDefault() } var topOffset = toolbar ? toolbar.getBoundingClientRect().bottom : headerNavigationBar.getBoundingClientRect().bottom - + var target = this + var tabs + if ((tabs = target.closest('.tabbed'))) { + target = tabs + } if (cheatSheet) { var scrollTarget = this.closest('div') var selectorsTop = document.querySelector('.nav-container .selectors').querySelector('div').getBoundingClientRect().top if (this.tagName === 'H3') topOffset = selectorsTop window.scrollTo(0, computePosition(scrollTarget, 0) - topOffset) } else { - window.scrollTo(0, computePosition(this, 0) - topOffset) + window.scrollTo(0, computePosition(target, 0) - topOffset) } } From bf475f254a15681e88b82ab131e7c07f5d689cae Mon Sep 17 00:00:00 2001 From: Adam Cowley Date: Wed, 6 Mar 2024 13:05:28 +0000 Subject: [PATCH 10/14] GraphAcademy Top-level Menu (#219) --- package-lock.json | 13 +++++----- src/partials/navbar-end.hbs | 50 +++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index a0f6194b..e33fd54b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@antora/cli": "^2.3.3", "@antora/site-generator-default": "^2.3.3", "@neo4j-ndl/base": "^2.0.0", + "@neo4j-ndl/base": "^2.0.0", "font-awesome": "^4.7.0" }, "devDependencies": { @@ -1022,9 +1023,9 @@ } }, "node_modules/@neo4j-ndl/base": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@neo4j-ndl/base/-/base-2.4.0.tgz", - "integrity": "sha512-LopFYglm7g5hESh0zSdEjzBg1hAGpb5V7T6omkhno2V+PimT+qr2IO9Knyg2/XH33HBcmJN9aVFdpEG4ibkPiw==" + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/@neo4j-ndl/base/-/base-2.7.1.tgz", + "integrity": "sha512-jsE4Um+5lnsW2S46FRaCidkNI+Qb7QkIr1hdHQyKXisTcBxRZKC1KsJ4/6LqxqyI5qOsu8AIAzlQyjBe9MvPFw==" }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.3", @@ -18383,9 +18384,9 @@ } }, "@neo4j-ndl/base": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@neo4j-ndl/base/-/base-2.4.0.tgz", - "integrity": "sha512-LopFYglm7g5hESh0zSdEjzBg1hAGpb5V7T6omkhno2V+PimT+qr2IO9Knyg2/XH33HBcmJN9aVFdpEG4ibkPiw==" + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/@neo4j-ndl/base/-/base-2.7.1.tgz", + "integrity": "sha512-jsE4Um+5lnsW2S46FRaCidkNI+Qb7QkIr1hdHQyKXisTcBxRZKC1KsJ4/6LqxqyI5qOsu8AIAzlQyjBe9MvPFw==" }, "@nodelib/fs.scandir": { "version": "2.1.3", diff --git a/src/partials/navbar-end.hbs b/src/partials/navbar-end.hbs index c7a54d9d..176b4879 100644 --- a/src/partials/navbar-end.hbs +++ b/src/partials/navbar-end.hbs @@ -41,9 +41,9 @@ @@ -204,14 +204,6 @@ +