Skip to content

Conversation

@lidavidm
Copy link
Member

@lidavidm lidavidm commented Dec 5, 2022

No description provided.

@lidavidm
Copy link
Member Author

lidavidm commented Dec 5, 2022

CC @nealrichardson I know you wanted to have /docs/adbc and /docs/dev/adbc, but it looks like .asf.yaml can only publish to a single subdirectory. So I've reverted to publishing to /adbc - maybe we can add redirects in the future? (Right now it'll end up as /adbc/dev for the dev docs, and nothing else, with my plan being to add /adbc/0.1.0 etc. for each version.)

@lidavidm lidavidm marked this pull request as ready for review December 12, 2022 16:26
@lidavidm lidavidm added this to the 0.1.0 milestone Dec 13, 2022
@lidavidm
Copy link
Member Author

CC @kou does this look OK? Maybe this should instead go under /adbc/docs so that in apache/arrow-site, we can generate an /adbc/index.html in Jekyll…

@lidavidm
Copy link
Member Author

Updated.

@kou
Copy link
Member

kou commented Dec 14, 2022

Why do we want to generate /adbc/index.html in Jekyll?
I think that it's better that we generate all files for https://arrow.apache.org/adbc/ in apache/arrow-adbc.

How about putting the latest documents to https://arrow.apache.org/adbc/ and the dev documents to https://arrow.apache.org/adbc/dev/ like https://arrow.apache.org/docs/ and https://arrow.apache.org/docs/dev/ ?

BTW, we need to copy .asf.yaml in main to asf-site to deploy https://arrow.apache.org/adbc/ .
See also: apache/arrow-site#115 and apache/arrow-site#116

@lidavidm
Copy link
Member Author

Why do we want to generate /adbc/index.html in Jekyll? I think that it's better that we generate all files for https://arrow.apache.org/adbc/ in apache/arrow-adbc.

I was thinking about having some sort of (brief) landing page, but it is redundant. (Or maybe a redirect, or a version selector.)

How about putting the latest documents to https://arrow.apache.org/adbc/ and the dev documents to https://arrow.apache.org/adbc/dev/ like https://arrow.apache.org/docs/ and https://arrow.apache.org/docs/dev/ ?

I wanted to have versioned documentation from the start, so it seems weird to me to have them nested like that. (I still need to look at different approaches to that, but something like https://github.com/steinwurf/versjon assumes each version falls in its own subdirectory.) But consistency probably matters more.

BTW, we need to copy .asf.yaml in main to asf-site to deploy https://arrow.apache.org/adbc/ . See also: apache/arrow-site#115 and apache/arrow-site#116

Ah, thank you.

@kou
Copy link
Member

kou commented Dec 14, 2022

I was thinking about having some sort of (brief) landing page, but it is redundant. (Or maybe a redirect, or a version selector.)

Ah, it makes sense.
I used the "redirect" approach in other project: https://hayamizu-lab.github.io/treefit-python/ (source: https://github.com/hayamizu-lab/treefit-python/blob/master/docs/index.html )

I wanted to have versioned documentation from the start, so it seems weird to me to have them nested like that.

I agree with you. FYI: I like the following URLs:

@kou
Copy link
Member

kou commented Dec 14, 2022

We can use apache/arrow-adbc for the "redirect" approach because we just need to put a simple HTML. We don't need to use the same design in https://arrow.apache.org/ for the approach.

@lidavidm
Copy link
Member Author

Cool. I've reverted it to deploy to adbc/. Also, I added https://github.com/steinwurf/versjon which generates the index.html with a redirect for us. It also embeds a version switcher into the docs, and generates a stable/index.html with a redirect (if it detects a stable version).

@lidavidm
Copy link
Member Author

Ah, versjon is not idempotent, hmm.

@lidavidm
Copy link
Member Author

I'll take a look at embedding it ourselves

@lidavidm
Copy link
Member Author

Ok…added a homegrown version switcher. It embeds a reference to a JavaScript file in the generated docs. The JavaScript file will sit in adbc/version.js and will have to be manually added to the asf-site branch. The contents are this:

Details
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

window.addEventListener("DOMContentLoaded", () => {
    // Injected by template
    window.fetch(versionListingPath)
        .then((r) => r.text())
        .then((text) => {
            const root = document.querySelector("#version-switcher ul");
            const versions = text
                  .trim()
                  .split(/\n/g)
                  .map((version) => {
                      return version.split(/;/);
                  });
            const versionRegex = /^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$/;
            versions.sort((x, y) => {
                const lhs = x[1].match(versionRegex);
                const rhs = y[1].match(versionRegex);
                if (lhs === null && rhs === null) {
                    return x[1].localeCompare(y[1]);
                }
                if (lhs === null) return 1;
                if (rhs === null) return -1;
                // Major
                const lhsMajor = parseInt(lhs[1], 10);
                const rhsMajor = parseInt(rhs[1], 10);
                if (lhsMajor < rhsMajor) {
                    return -1;
                } else if (lhsMajor > rhsMajor) {
                    return 1;
                }

                const lhsMinor = parseInt(lhs[2], 10);
                const rhsMinor = parseInt(rhs[2], 10);
                if (lhsMinor < rhsMinor) {
                    return -1;
                } else if (lhsMinor > rhsMinor) {
                    return 1;
                }

                const lhsPatch = parseInt(lhs[3], 10);
                const rhsPatch = parseInt(rhs[3], 10);
                if (lhsPatch < rhsPatch) {
                    return -1;
                } else if (lhsPatch > rhsPatch) {
                    return 1;
                }

                return lhs[4].localeCompare(rhs[4]);
            });
            versions.forEach((version) => {
                const el = document.createElement("a");
                el.setAttribute("href", versionsRoot + "/" + version[0]);
                el.innerText = version[1];
                if (version[1] === currentVersion) {
                    el.classList.toggle("active");
                }
                const li = document.createElement("li");
                li.appendChild(el);
                root.appendChild(li);
            });
        });
});

It just populates a list embedded in the docs. The generated docs style the list. The versions are pulled from a text file that we can generate in CI.

@lidavidm
Copy link
Member Author

It looks like this:

image

image

(screenshot doesn't capture it, but it scrolls)

@lidavidm
Copy link
Member Author

Unlike versjon, because it doesn't modify the docs HTML, it is idempotent. We can update the switcher in all docs just by updating the text file and/or JavaScript file. (We could save a round-trip with some more acrobatics, by templating the JavaScript file with the contents of the text file, but we can always do that later without having to regenerate docs.)

@lidavidm
Copy link
Member Author

Demo here: https://github.com/lidavidm/arrow-adbc/tree/asf-site

(check out the branch and run python -m http.server 12345, then visit localhost:12345)

And then in the release PR, I can have the action generate an index.html and a latest that redirect to the docs from the newly pushed tag. (I suppose that'll backfire if we eventually do patch releases/we'll eventually need a version comparator there.)

@lidavidm
Copy link
Member Author

lidavidm commented Dec 14, 2022

Also updated that branch with the results of pushing a tag (which also generated index.html and latest/), though the 0.1.0 subdir is missing the version switcher because it doesn't have the changes here.

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

@kou
Copy link
Member

kou commented Dec 15, 2022

The JavaScript file will sit in adbc/version.js and will have to be manually added to the asf-site branch.

How about maintaining it in the main branch and just copying it to the asf-site branch on publish?

@lidavidm
Copy link
Member Author

Ok! In that case I'll also move this Bash code out into actual scripts

@lidavidm
Copy link
Member Author

lidavidm commented Dec 15, 2022

Updated!

  1. Bash scripts in YAML replaced with an actual script
  2. Version list embedded in the JS file to avoid a network round-trip
  3. Version list pre-sorted in Bash so we don't have to duplicate it in JavaScript
  4. Script handles tagged versions so we can avoid duplicating the action code for release

Since I switched from dev/ to main/, after this PR I'll make a PR to asf-site to remove dev/ since it'll generate a blank version

@lidavidm
Copy link
Member Author

@lidavidm
Copy link
Member Author

lidavidm commented Dec 15, 2022

Hmm, one bug in the script now that I need to fix... (fixed)

@lidavidm
Copy link
Member Author

And #246 to prepare for deployment

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

@lidavidm
Copy link
Member Author

Thanks so much for your help!

@lidavidm lidavidm merged commit 6507ebe into apache:main Dec 15, 2022
lidavidm added a commit that referenced this pull request Dec 15, 2022
Remove the old 'dev' directory since #218 will change the deployment; add asf.yaml so this can be deployed.
@lidavidm lidavidm deleted the site branch December 15, 2022 21:27
@lidavidm
Copy link
Member Author

It works! https://arrow.apache.org/adbc/

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.

2 participants