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

url shortening, use GitHub octokit.js to show issue/pull status. #1895

Open
Carreau opened this issue Jun 20, 2024 · 3 comments
Open

url shortening, use GitHub octokit.js to show issue/pull status. #1895

Carreau opened this issue Jun 20, 2024 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind: enhancement New feature or request needs: discussion Needs discussion before an implementation can be made tag: CSS CSS and SCSS related issues tag: javascript Pull requests that update Javascript code tag: UX Issues or improvements related to user experience

Comments

@Carreau
Copy link
Collaborator

Carreau commented Jun 20, 2024

currently we are shortening github/gitlab url at build time,

It should be possible to use ocktokit js to run all all link on a page matching a specific pattern and mark the issue/PRs as closed/opened/merged,
for example, the following fetch a open|close issue of IPython and a closed|opened|merged PR.

<script type="module">
import { Octokit, App } from "https://esm.sh/octokit";
const octokit = new Octokit();


for(var ni of [14454,14453,14464,14462,14460]){

    const res = await octokit.request('GET /repos/ipython/ipython/issues/'+ni, {
      //owner: 'OWNER',
      //repo: 'REPO',
      //issue_number: 'ISSUE_NUMBER',
      headers: {
        'X-GitHub-Api-Version': '2022-11-28'
      }
    })

    //console.info('res', ni, res.data)
    if (res.data.pull_request != undefined){
        console.info('is pull', res.data.pull_request.merged_at != null ? 'merged': res.data.state ); 
    } else {
        console.info('is issue',res.data.state);

    }
}

mixed with something like :

var anchorTags = document.querySelectorAll('a');

// Regular expression to match the desired GitHub issue URL pattern
var regex = /^https:\/\/github\.com\/[^\/]+\/[^\/]+\/issues\/\d+$/;

// Filter <a> tags that match the pattern
var githubIssueLinks = Array.prototype.filter.call(anchorTags, function(element) {
    return regex.test(element.href);
});

We should be able to find all links to Pulls/issues, and then I suggest adding a given class to the a (pst-github-[issue|pr|unknown]-[open|close|merged|unknonw]) that can be later targeted by css to either add a :before icon or change the styling.

@Carreau Carreau added kind: enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers tag: CSS CSS and SCSS related issues needs: discussion Needs discussion before an implementation can be made impact: block-release Should block a release from happening. Only use if this is a critical problem we don't want to ship tag: javascript Pull requests that update Javascript code tag: UX Issues or improvements related to user experience labels Jun 20, 2024
Carreau added a commit to Carreau/pydata-sphinx-theme that referenced this issue Jun 20, 2024
See pydata#1895.

Not that I heve the right skills and am good at desing, just show what
could be done.

Need to be pulled into a separate JS file and properely desinged.
@Carreau Carreau removed the impact: block-release Should block a release from happening. Only use if this is a critical problem we don't want to ship label Aug 7, 2024
@Carreau
Copy link
Collaborator Author

Carreau commented Aug 7, 2024

I probably added release blocker by mistake, removing.

Carreau added a commit to Carreau/pydata-sphinx-theme that referenced this issue Sep 11, 2024
See pydata#1895.

Not that I heve the right skills and am good at desing, just show what
could be done.

Need to be pulled into a separate JS file and properely desinged.
Carreau added a commit to Carreau/pydata-sphinx-theme that referenced this issue Sep 30, 2024
See pydata#1895.

Not that I heve the right skills and am good at desing, just show what
could be done.

Need to be pulled into a separate JS file and properely desinged.
@12rambau
Copy link
Collaborator

I recently found the following sphinx-extention that seems to mach what you try to achieve: https://sphinx-hoverxref.readthedocs.io/en/latest/.

@Carreau
Copy link
Collaborator Author

Carreau commented Nov 11, 2024

Thanks; I don't think it does the same; I am aware of hoverxref, but for what I'm trying to achieve see #1896, which I don't think hxref does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind: enhancement New feature or request needs: discussion Needs discussion before an implementation can be made tag: CSS CSS and SCSS related issues tag: javascript Pull requests that update Javascript code tag: UX Issues or improvements related to user experience
Projects
None yet
Development

No branches or pull requests

2 participants