Skip to content

ci: doc: link to the generated docs once the CI doc build has run successfully #63020

@ghost

Description

Problem Description

We have a nice hidden feature that the doc being built for a PR is actually available for download/viewing. It would be nice if that feature could be made more visible (e.g. as proposed by @kartben as an automatic comment).

Proposed Solution

Similar to @kartben 's nice little browser script:

// ==UserScript==
// @name         Show link to CI-built docs for a Zephyr PR
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  add link to CI doc site
// @author       You
// @match        https://github.com/zephyrproject-rtos/zephyr/pull/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const addDocsLink = () => {
        const PRNumberRegex = /(\d+)/g;
        let targetElement = document.querySelector(".gh-header-title");

        if (targetElement) {
            // Get PR number from URL
            let prNumber = window.location.pathname.split("/").pop();
            if (PRNumberRegex.test(prNumber)) {
                let container = document.createElement('div');

                let docLink = document.createElement('a');
                docLink.href = `https://builds.zephyrproject.io/zephyr/pr/${prNumber}/docs/`;
                docLink.target = "_blank";
                docLink.innerText = `here`;

                container.appendChild(document.createTextNode('CI-built documentation: '));
                container.appendChild(docLink); 
                container.appendChild(document.createElement('br'));

                targetElement.parentNode.parentNode.insertBefore(container, targetElement.parentNode);
            }
        }
    };

    addDocsLink();
})();

Alternatives

./.

Additional context

Has come up several times as a question on Discord plus would probably actively promote active review of doc results by both, contributors and reviewers.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions