Skip to content

Commit f323ede

Browse files
mlreric-schneider
andauthored
Updates for unified build (#406)
* Updates for unified doc site * Add workflow for pull request draft builds * Add unified docs assets * Remove external-link-icon attribute references --------- Co-authored-by: Eric Schneider <[email protected]>
1 parent 0200db3 commit f323ede

25 files changed

+2742
-1318
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy Draft
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '*'
7+
8+
jobs:
9+
dispatch-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# Determine the build branch and draft branch for dispatch.
14+
- name: Determine Dispatch Parameters
15+
run: |
16+
if [ "${{ github.event_name }}" == "pull_request" ]; then
17+
# If this workflow is kicked off by a pull request, build
18+
# a draft using the pull request base branch and PR branch.
19+
build_branch="${{ github.base_ref }}"
20+
draft_branch="${{ github.event.pull_request.head.ref }}"
21+
else
22+
if [ "$(basename ${{ github.event.ref }})" == "stage" ]; then
23+
# This was a merge to stage so kick off a build to update stage draft.
24+
build_branch=stage
25+
draft_branch=stage
26+
else
27+
# Otherwise this is a push to one of the source branches so
28+
# dispatch a build for the main draft to pick up the changes.
29+
build_branch=main
30+
draft_branch=main
31+
fi
32+
fi
33+
echo "build_branch=$build_branch" >> $GITHUB_OUTPUT
34+
echo "draft_branch=$draft_branch" >> $GITHUB_OUTPUT
35+
id: branches
36+
37+
- name: Deploy Draft
38+
uses: convictional/[email protected]
39+
with:
40+
owner: riptano
41+
repo: datastax-docs-site
42+
github_token: ${{ secrets.DISPATCH_GITHUB_TOKEN }}
43+
github_user: ${{ secrets.DISPATCH_GITHUB_USER }}
44+
workflow_file_name: deploy-draft.yml
45+
client_payload: '{ "build_repository": "${{ github.event.repository.full_name }}", "build_branch": "${{ steps.branches.outputs.build_branch }}", "draft_branch": "${{ steps.branches.outputs.draft_branch }}", "pull_request_number": "${{ github.event.pull_request.number }}" }'

docs/.gitignore

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
node_modules/
2-
build/
1+
#OS
2+
**/.DS_Store
3+
**/.git-credentials
4+
5+
#IDE
6+
**/.vscode/
7+
**/.idea
8+
**/*.iml
9+
*.http
10+
**/.java-version
11+
12+
#build
13+
**/package-lock.json
14+
**/node_modules/
15+
/build/

docs/README.adoc

Lines changed: 88 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,158 @@
1-
= {company} {product} Docs
1+
= {product} Docs
22
// Variables:
33
:product: RAGStack
4-
:company: DataStax
4+
:repo-name: ragstack-ai
5+
:github-org: datastax
56
// Settings:
7+
:toc: macro
68
:!example-caption:
79
:experimental:
810
:hide-uri-scheme:
9-
:toc: macro
1011
ifdef::env-github[]
1112
:icons: font
13+
:toclevels: 1
14+
:toc-title: Contents
1215
:tip-caption: :bulb:
1316
:note-caption: :information_source:
1417
:important-caption: :heavy_exclamation_mark:
1518
:caution-caption: :fire:
1619
:warning-caption: :warning:
1720
:badges:
1821
endif::[]
19-
// URLs:
20-
:url-org: https://github.com/datastax
22+
// Project URLs:
23+
:url-github-org: https://github.com/{github-org}
24+
:url-project-repo: {url-github-org}/{repo-name}
25+
:url-ui-repo: https://github.com/riptano/docs-ui
26+
:url-playbook-repo: https://github.com/riptano/datastax-docs-site
27+
:url-contribute:
2128
:url-datastax: https://datastax.com
2229
:url-datastax-docs: https://docs.datastax.com
23-
:url-asciidoc-docs: https://docs.asciidoctor.org/asciidoc/latest/
30+
:url-docs-preview: http://docs-preview.datastax.com
31+
// External URLs:
32+
:asciidoc-language: https://docs.asciidoctor.org/asciidoc/latest/
33+
34+
This repository contains the source files for the {product} documentation.
35+
36+
toc::[]
37+
38+
== Get started
39+
40+
The documentation is written in {asciidoc-language}[AsciiDoc]-formatted source files located in the `modules` directory.
41+
42+
=== Make a simple update
43+
44+
For simple updates like fixing typos or modifying existing prose, it's easiest to edit the source files directly on GitHub.
45+
46+
NOTE: You'll need Write privileges on the repository to edit files directly on GitHub.
47+
48+
. Find the file you want to edit in the `modules` directory.
49+
50+
. Click the *Edit* icon in the upper-right corner of the file view.
51+
52+
. Make your changes in the editor.
53+
54+
. Click *Commit changes...*
2455

56+
. Enter a description for your commit and click *Propose changes*.
2557

26-
Documentation source for {company} {product}.
58+
. On the *Open a pull request* screen, enter a title and description for your change, assign reviewers, then click *Create pull request*.
2759

28-
== Build docs locally
60+
. Once the pull request is open, an automatic draft preview build is triggered.
61+
Once complete, the build system posts a comment on the pull request with a link to the draft site for you to preview your changes.
2962

30-
. Clone this repository.
63+
=== Edit docs locally
64+
65+
If you need to make substantial updates to the documentation, you'll want to clone the repository so you can work with the source files locally.
66+
67+
. Clone this repository
3168
+
32-
[source,shell]
69+
[source,bash,subs="attributes"]
3370
----
34-
git clone https://github.com/datastax/ragstack-ai.git
71+
git clone {url-project-repo}.git
3572
----
3673

74+
. https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic[Create a _classic_ personal access token] for your GitHub account.
75+
When configuring the token, set the *Expiration* to at least 90 days and select everything under the *Repo* https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps#available-scopes[scope].
76+
+
77+
[IMPORTANT]
78+
====
79+
Copy your personal access token to a temporary location -- you'll need it later.
80+
====
81+
82+
. https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on[Authorize your personal access token] so that it can access repositories in the Riptano and DataStax organizations in GitHub.
83+
84+
. https://docs.antora.org/antora/latest/playbook/private-repository-auth/#populate-credentials-directly[Populate the credential store] with your personal access token.
85+
For most people this means doing the following:
86+
+
87+
.. Create the file `$HOME/.git-credentials` and open it in your editor.
88+
.. Add the following line:
89+
+
90+
[source,subs="verbatim,quotes"]
91+
----
92+
https://**TOKEN**:@github.com
93+
----
94+
+
95+
Replace *`TOKEN`* with the personal access token you copied from GitHub.
96+
.. Save and close the file.
97+
3798
. If you don't already have Node.js installed, do the following:
3899

39100
.. Install https://github.com/nvm-sh/nvm[nvm].
40101
+
41102
If you're on macOS, you can install nvm using https://brew.sh/[Homebrew]:
42103
+
43-
[source,shell]
104+
[source,bash]
44105
----
45106
brew install nvm
46107
----
47108

48109
.. Use nvm to install Node.js.
49110
+
50-
[source,shell]
111+
[source,bash]
51112
----
52113
nvm install --lts
53114
----
54115
+
55-
[source,shell]
116+
[source,bash]
56117
----
57118
nvm use --lts
58119
----
59120
+
60-
[source,shell]
121+
[source,bash]
61122
----
62123
nvm alias default node
63124
----
64125

65126
. Install the project dependencies.
66127
+
67-
[source,shell]
128+
[source,bash,subs="attributes"]
68129
----
69-
cd ragstack-ai/docs
130+
cd {repo-name}
70131
----
71132
+
72-
[source,shell]
133+
[source,bash]
73134
----
74135
npm install
75136
----
76137

77138
. Build the site.
78139
+
79-
[source,shell]
140+
[source,bash]
80141
----
81-
npm run build:local:ragstack
142+
npm run build:local
82143
----
83144
+
84145
If the build was successful, you'll see the following output in your terminal:
85146
+
86-
[source,console]
147+
[source,console,subs="attributes"]
87148
----
88149
Site generation complete!
89-
Open file:///absolute-path-to-repo/ragstack-ai/docs/build/site/index.html in a browser to view your site.
150+
Open file:///Users/USERNAME/repos/{repo-name}/build/site/index.html in a browser to view your site.
90151
----
91152
+
92153
To view the site, paste the entire `\file:///` path into your browser's address bar and press kbd:[Return].
154+
155+
[#publish-docs]
156+
== Publish docs
157+
158+
To learn how to publish documentation to {url-datastax-docs}, see the {url-playbook-repo}#deploy-production[datastax-docs-site README].

docs/antora-ragstack.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

docs/antora.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/antora.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: ragstack
2+
version: ~
3+
title: 'RAGStack'
4+
start_page: ROOT:index.adoc
5+
asciidoc:
6+
attributes:
7+
company: 'DataStax'
8+
product: 'RAGStack'
9+
db-cassandra: 'Astra DB Serverless (Non-Vector)'
10+
db-vector: 'Astra DB Serverless'
11+
db-serverless: 'Astra DB Serverless'
12+
astra-ui: 'Astra Portal'
13+
nav:
14+
- modules/ROOT/nav.adoc

docs/extensions/svg-macro.js

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
const logger = require("@antora/logger")("asciidoctor:svg-macro");
2+
3+
/**
4+
* @example Inline Embedded SVG
5+
* svg:ROOT:ui/icons/vector.svg[]
6+
*/
7+
function inlineSvgMacro({ contentCatalog, file }) {
8+
return function () {
9+
this.process((parent, target, attrs) => {
10+
svgContent = getSvgContent(target, file, contentCatalog);
11+
if (!svgContent) return;
12+
return this.createInlinePass(
13+
parent,
14+
svgContent.replace("<svg", `<svg ${htmlAttrs(attrs)}`)
15+
);
16+
});
17+
};
18+
}
19+
20+
/**
21+
* @example Block Embedded SVG
22+
* svg::home:diagrams/graphic.svg[alt="My Graphic"]
23+
*/
24+
function blockSvgMacro({ contentCatalog, file }) {
25+
return function () {
26+
this.process((parent, target, attrs) => {
27+
svgContent = getSvgContent(target, file, contentCatalog);
28+
if (!svgContent) return;
29+
const svgHtmlAttrs = htmlAttrs({ ...attrs, role: undefined });
30+
const containerHtmlAttrs = attrs.role
31+
? `class="imageblock ${attrs.role}"`
32+
: 'class="imageblock"';
33+
const html =
34+
`<div ${containerHtmlAttrs}><div class="content">` +
35+
svgContent.replace("<svg", `<svg ${svgHtmlAttrs}`) +
36+
"</div></div>";
37+
return this.createBlock(parent, "pass", html);
38+
});
39+
};
40+
}
41+
42+
/**
43+
* This macro relies on the material-icons font being loaded in UI bundle.
44+
*
45+
* @example Material Icon
46+
* icon:material-icons:menu_open[]
47+
*
48+
* @example Embedded SVG
49+
* icon:ROOT:ui/icons/vector.svg[]
50+
*/
51+
function inlineIconMacro({ contentCatalog, file }) {
52+
return function () {
53+
this.process((parent, target, attrs) => {
54+
if (target.startsWith("material-icons")) {
55+
iconTarget = target
56+
.replace("material-icons:", "")
57+
.trim()
58+
.replace("-", "_");
59+
return this.createInlinePass(
60+
parent,
61+
`<i ${htmlAttrs(attrs, "material-icons icon")}>${iconTarget}</i>`
62+
);
63+
} else {
64+
svgContent = getSvgContent(target, file, contentCatalog);
65+
if (!svgContent) return;
66+
return this.createInlinePass(
67+
parent,
68+
svgContent.replace("<svg", `<svg ${htmlAttrs(attrs, "svg icon")}`)
69+
);
70+
}
71+
});
72+
};
73+
}
74+
75+
function getSvgContent(target, file, contentCatalog) {
76+
svgFile = contentCatalog.resolveResource(target, file.src, "image", [
77+
"image",
78+
]);
79+
if (!svgFile)
80+
return logger.error({ target, file }, `target of svg not found: ${target}`);
81+
svgContent = svgFile.contents.toString();
82+
if (!svgContent.startsWith("<svg"))
83+
return logger.error({ target, file }, "file contents must be a valid svg");
84+
return svgContent;
85+
}
86+
87+
function htmlAttrs({ width, height, role, alt, title }, klass = "svg") {
88+
return [
89+
width && `width="${width}"`,
90+
height && `height="${height}"`,
91+
role ? `class="${klass} ${role}"` : `class="${klass}"`,
92+
alt && `aria-label="${alt}"`,
93+
title && `aria-label="${title}"`,
94+
(alt || title) && 'role="img"',
95+
]
96+
.filter(Boolean)
97+
.join(" ");
98+
}
99+
100+
/**
101+
* @param { import("@asciidoctor/core/types").Asciidoctor.Extensions.Registry } registry
102+
* @param context
103+
*/
104+
function register(registry, context) {
105+
registry.inlineMacro("svg", inlineSvgMacro(context));
106+
registry.blockMacro("svg", blockSvgMacro(context));
107+
registry.inlineMacro("icon", inlineIconMacro(context));
108+
}
109+
110+
module.exports.register = register;

0 commit comments

Comments
 (0)