Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASSANDRA-19915 Upgrade for the native protocols spec page #282

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

tengu-alt
Copy link

This PR enhances the Native Protocols page by replacing the plain text with an interactive, section-based navigation. The implementation leverages cqlprotodoc tool that converts CQL protocol specification files into HTML.

A .sh script was added to download cqlprotodoc, convert the .spec files containing the native protocol specifications into HTML pages, and then merge them into a single page.

After that, native protocols page looks like this:
image
The navigation is clickable, so you can move to the desired section.
image

@tengu-alt tengu-alt force-pushed the native-protocols-page-upgrade branch from 8391401 to fc53c8c Compare August 30, 2024 12:11
# Variables
GO_VERSION="1.20.6"
GO_TAR="go${GO_VERSION}.linux-amd64.tar.gz"
GITHUB_REPO_PARSER="https://github.com/martin-sucha/cqlprotodoc.git" # Replace with the actual parser repo URL
Copy link
Member

@michaelsembwever michaelsembwever Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitant to leave this pointing to a living branch. Pinning it to a SHA would be safest.

And am curious if we could upstream it to here… (but this can happen separately…)

@martin-sucha, would you be willing to upstream it (to either cassandra-website or cassandra-builds) ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is better to copy it under github.com/apache (I'll leave up to you to which repo). I'm willing to donate the cqlprotodoc code to the Apache software foundation and change the licence to Apache license, Version 2.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @martin-sucha. That's all the approval/consent we need.

@tengu-alt , are you willing (and got the time) to include the contents of the repo in the folder cqlprotodoc and adjust accordingly, in this PR ? (don't include its LICENSE file, add to its readme a sentence about where it comes from)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @martin-sucha. That's all the approval/consent we need.

@tengu-alt , are you willing (and got the time) to include the contents of the repo in the folder cqlprotodoc and adjust accordingly, in this PR ? (don't include its LICENSE file, add to its readme a sentence about where it comes from)

Sure! I will do it.

@michaelsembwever
Copy link
Member

This is a solid piece of work, and valuable addition to the website !!

@ossarga , would you be interested in glancing over this in review, as it touches on your past work ?

@tengu-alt tengu-alt force-pushed the native-protocols-page-upgrade branch 3 times, most recently from 2bb65c0 to 3aba510 Compare September 3, 2024 13:52
cqlprotodoc/README.md Outdated Show resolved Hide resolved
@tengu-alt tengu-alt force-pushed the native-protocols-page-upgrade branch from 3aba510 to c55a221 Compare September 5, 2024 12:03
Copy link
Member

@michaelsembwever michaelsembwever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks again @tengu-alt ! final approving depends on the other reviewers.

site-content/process-native-protocol-specs-in-docker.sh Outdated Show resolved Hide resolved

[source, js]
++++
<script>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we moved the cqlprotodoc code here, I wonder if including the content using Javascript is still needed or whether we should modify the template.gohtml / cqlprotodoc output and include the html files directly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to keep things as they are because the script placed in the .adoc template appears more readable to me. Also, we avoid changing the website template by keeping native_protocol.html as the location where the generated pages are merged.

@tengu-alt
Copy link
Author

tengu-alt commented Sep 6, 2024

LGTM. Thanks again @tengu-alt ! final approving depends on the other reviewers.

Thanks a lot! Will wait for reviews :)

@tengu-alt tengu-alt force-pushed the native-protocols-page-upgrade branch from c55a221 to f1f5b4d Compare September 6, 2024 08:45
Copy link

@martin-sucha martin-sucha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good to me. I'll leave up to you whether to change to directly include the contents instead of using Javascript.

@tengu-alt
Copy link
Author

Thanks! Looks good to me. I'll leave up to you whether to change to directly include the contents instead of using Javascript.

Thank you!

@smiklosovic
Copy link
Contributor

going to merge this soon.

@smiklosovic
Copy link
Contributor

@tengu-alt can you please tell me how you succeeded to render this locally? All I am getting is this:

image

I checked out your branch and did ./run.sh website build and opened this page in the browser:

file:///home/fermat/dev/cassandra/cassandra-website/site-content/build/html/_/native_protocol.html

@smiklosovic
Copy link
Contributor

I have also run ./run.sh website container to build the image (not sure why that command is called "container" though) which adds new shell script but the result is the same.

@smiklosovic smiklosovic changed the title Upgrade for the native protocols spec page CASSANDRA-19915 Upgrade for the native protocols spec page Sep 12, 2024
@tengu-alt
Copy link
Author

@smiklosovic you need to build an image from a Dockerfile inside of the site-content directory and provide the tag:
docker build . -t <tag>
And use this image when you run the ./run.sh script
./run.sh website build -c <tag>

@tengu-alt
Copy link
Author

I have also run ./run.sh website container to build the image (not sure why that command is called "container" though) which adds new shell script but the result is the same.

@smiklosovic Has my advice helped solve the build issue?

@smiklosovic
Copy link
Contributor

@tengu-alt I did what you suggested, it is still same. After your steps I just do

$ open content/_/native_protocol.html

firefox opens that patch and I just have same results as shown in the comment from (1)

(1) #282 (comment)

@smiklosovic
Copy link
Contributor

@michaelsembwever does this render fine for you based on the steps @tengu-alt gave? I am a little bit out of options here.

@michaelsembwever
Copy link
Member

michaelsembwever commented Nov 1, 2024

Because of the site-ui/ change in the PR, the way to build this should be

./run.sh website container
./run.sh website build

This is what's documented in this repo's README, and it is how ci-cassandra.apache.org builds the website (so it needs to work this way).
ref: https://github.com/apache/cassandra-builds/blob/trunk/jenkins-dsl/cassandra_job_dsl_seed.groovy#L1401-L1414

This looks to work for me, at least i'm getting the content/_/native_protocol_v*.html pages.
But the content/_/native_protocol.html is still the same as Stefan's screenshot above.
build logs in https://gist.github.com/michaelsembwever/ae8611f4d62e227d02aef9fc89e64657

(It would also be nice to turn off the progress reporting as go downloads…)

@tengu-alt
Copy link
Author

@smiklosovic Now I see. There are some issues with iFrame and document origin. I will fix it.

@tengu-alt
Copy link
Author

tengu-alt commented Nov 4, 2024

@smiklosovic I've done some research, and it turns out that the browser does not show the content because the page is loaded using the file:// protocol (when you open it via open, google-chrome etc.) which is treated as null origin by the browser, and content is blocked by the CORS policy .
When I open the file by IDE(which serve it over localhost:) it's work just fine.
Could you please try running it on the local HTTP server (e.g. open file thought IDE) and let me know if it resolves the issue?

[source, js]
++++
<div id="contentv3" class="doc-container"></div>
<iframe id="iframev3" src="native_protocol_v3.html" style="display:none;"></iframe>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to include the generated native_protocol_v3.html page, instead of using an iframe ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be done using the fetch but it's relying on the same CORS policy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it not be included (somehow) at antora build time ? if possible that would be the best IMO.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please clarify - did you mean the JavaScript contained within the .adoc file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. javascript and iframes are all doing the including at view time.

we should be embedding the html contents into the other file at antora build time.

Copy link
Member

@michaelsembwever michaelsembwever Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what i mean: c7b6b60

note, some small things are still needed on top of that^
(e.g. there's links in the headers of each page that don't work, and we need gitignore if we have to put the generated files under site-content)

(feel free to squash that commit into your work here)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. I'll try to move it into the .hbs layout.

Copy link
Member

@michaelsembwever michaelsembwever Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also… there's another thing we might want cleaned up here.

The native protocol spec files are actually here:
https://github.com/apache/cassandra/tree/trunk/doc

They're the source of truth, and those that will be kept up to date.

IUUC the ones in cassandra-website are unnecessary duplicates: https://github.com/apache/cassandra-website/tree/trunk/site-content/source/modules/ROOT/examples/TEXT

We can assume that these from apache/cassandra:trunk are accurate. And delete the examples/TEXT directory. And then it might be possible then to not need any gitignore addition.

Going further, we could also remove the native_protocol.adoc file from casandra-website altogether, move it to here instead: https://github.com/apache/cassandra/tree/trunk/doc/modules/cassandra/pages

(this would mean running process-native-protocol-specs-in-docker.sh on each generate_cassandra_versioned_docs())

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great! I'll apply it.

@tengu-alt
Copy link
Author

@smiklosovic I have to update my solution: for some reason the files that we need for the complete page render are not stored under the site-content directory but under the content(I'm gonna fix it) and you have to look the native_protocol.html under the content dir. (solution about CORS policy and the file:// protocol is actual)

@smiklosovic
Copy link
Contributor

@tengu-alt I would prefer to wait until the complete / working solution is in place, if you do not mind.

@tengu-alt tengu-alt force-pushed the native-protocols-page-upgrade branch from f1f5b4d to b141c20 Compare November 26, 2024 14:20
@tengu-alt
Copy link
Author

tengu-alt commented Nov 26, 2024

@michaelsembwever I have moved the HTML and JavaScript from the native_protocol.adoc file into the new .hbs layout, which is now responsible for it. Additionally, the native_protocol.spec files are currently fetched from the Apache Cassandra GitHub repository.

The issue with the headers arises because the native_protocol_v*.spec files contain typos that cause problems.
(e.g. https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v3.spec#L719-L740)
I can create a pull request for Cassandra to fix these typos.

Could you also clarify why we need to move the native_protocol.adoc file into the Cassandra repository and run the process-native-protocol-specs-in-docker.sh on each generate_cassandra_versioned_docs() execution? As I understand it, the native protocol spec page is identical for all Cassandra versions.

@tengu-alt
Copy link
Author

@tengu-alt I would prefer to wait until the complete / working solution is in place, if you do not mind.

The native_protocol_v*.spec files now appears in both content and site-content dirs. (solution about CORS policy and the file:// protocol is actual)

@michaelsembwever
Copy link
Member

I can create a pull request for Cassandra to fix these typos.

Please do, thanks!

Could you also clarify why we need to move the native_protocol.adoc file into the Cassandra repository and run the process-native-protocol-specs-in-docker.sh on each generate_cassandra_versioned_docs() execution?

The .spec files are originally found under https://github.com/apache/cassandra/tree/trunk/doc/
They won't be necessarily be identical on each branch. i.e. when v6 is introduced it will only be found initially in the trunk branch.

@tengu-alt
Copy link
Author

tengu-alt commented Nov 27, 2024

I can create a pull request for Cassandra to fix these typos.

Please do, thanks!

Done: apache/cassandra#3714

@tengu-alt
Copy link
Author

I can create a pull request for Cassandra to fix these typos.

Please do, thanks!

Could you also clarify why we need to move the native_protocol.adoc file into the Cassandra repository and run the process-native-protocol-specs-in-docker.sh on each generate_cassandra_versioned_docs() execution?

The .spec files are originally found under https://github.com/apache/cassandra/tree/trunk/doc/ They won't be necessarily be identical on each branch. i.e. when v6 is introduced it will only be found initially in the trunk branch.

Understood, working on it.

@michaelsembwever
Copy link
Member

The .spec files are originally found under https://github.com/apache/cassandra/tree/trunk/doc/ They won't be necessarily be identical on each branch. i.e. when v6 is introduced it will only be found initially in the trunk branch.

I've taken your latest work @tengu-alt and working it a bit.
Expect the patch-on-patch from me either in Dec' or in the new year.

@tengu-alt
Copy link
Author

tengu-alt commented Dec 5, 2024

The .spec files are originally found under https://github.com/apache/cassandra/tree/trunk/doc/ They won't be necessarily be identical on each branch. i.e. when v6 is introduced it will only be found initially in the trunk branch.

I've taken your latest work @tengu-alt and working it a bit. Expect the patch-on-patch from me either in Dec' or in the new year.

I am currently Implementing the protocol pages generation on each version(Maybe it will not be done exactly inside the generate_cassandra_versioned_docs ).
Thanks for the help! What kind of patch do I need to expect?

@michaelsembwever
Copy link
Member

What kind of patch do I need to expect?

Ah, i misunderstood you – didn't realise you were still in-progress…
this is the work-in-progress
tengu-alt@c06aa65
it's still a bit messy, but maybe you get the drift.

@tengu-alt
Copy link
Author

tengu-alt commented Dec 6, 2024

What kind of patch do I need to expect?

Ah, i misunderstood you – didn't realise you were still in-progress… this is the work-in-progress tengu-alt@c06aa65 it's still a bit messy, but maybe you get the drift.

The process-native-protocol-specs-in-docker.sh will look differently, and will be called not from the generate_cassandra_versioned_docs because the script needs to be run after the render_site_content_to_html, which cleans all generated files.
It takes the .spec files from Cassandra/doc, and site-content/build/html/Cassandra/$DOC_VERSION/cassandra/native-protocol is the output dir(I've created the native-protocol dir in the Cassandra repo, so we can have different native protocol doc pages for the different Cassandra versions
Let's apply your changes from work-in-progress (e.g. Dockerfile changes) after my next patch if you don't mind.

@michaelsembwever
Copy link
Member

Let's apply your changes from work-in-progress (e.g. Dockerfile changes) after my next patch if you don't mind.

Go for it. It's only for reference sake, and might not be used at all depending on what you land 👍

@tengu-alt tengu-alt force-pushed the native-protocols-page-upgrade branch from b141c20 to cb3b785 Compare December 11, 2024 15:47
@tengu-alt
Copy link
Author

tengu-alt commented Dec 11, 2024

@michaelsembwever I have done some refactoring on the process-native-protocol-specs-in-docker.sh.
From now, the script is called only if generate docs command for build is running (also implemented it for preview mode, but it throws some errors when generate docs is running. I've also tested it on the master branch, and it's the same).
I also moved the native_protocol.adoc file to the Cassandra Doc under the native-protocol directory, and antora generates a page using the .hbs layout from the website. The native_protocol.adoc needs to be in the Cassandra repo.

The generate_native_protocol_specs_pages() now iterates over specified Cassandra versions and calls the script if the provided version of Cassandra contains the native-protocol dir under the doc.
After that generated pages are put into the same versioned doc directory under the site-content and copied into the content.

The generate_native_protocol_specs_pages() can't be called with thegenerate_cassandra_versioned_docs() because the script needs to be run after the render_site_content_to_html because antora removes the generated files.

(I also added the license part inside script)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants