Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Testtimescaling Testtimescaling github io Json Dump Shields Badge

From Leeroopedia


Metadata
Page Type Implementation
Implementation Type API Doc
Domain Documentation, CI_CD
Namespace Testtimescaling_Testtimescaling_github_io
Workflow Automated_Citation_Tracking
Date Created 2026-02-14
Principle Principle:Testtimescaling_Testtimescaling_github_io_Badge_Data_Generation
Knowledge Source testtimescaling.github.io, Shields.io Endpoint

Overview

This implementation generates a Shields.io-compatible JSON file (arxiv_citations.json) containing the total citation count for the project's arXiv papers.

Description

After the citation counts for all tracked arXiv papers have been fetched and summed, this code block constructs a JSON dictionary conforming to the Shields.io endpoint badge schema and writes it to arxiv_citations.json in the repository root. The JSON file contains four fields: schemaVersion (always 1), label ("arXiv Citations"), message (the total citation count as a string), and color ("blue").

Once committed and pushed to the repository, this JSON file is served via GitHub Pages at a public URL. Shields.io reads this URL to dynamically render the citation count badge.

Usage

This code runs as part of the update_arxiv_citations.py script, after all individual paper citation counts have been fetched and aggregated. The generated file is then staged and committed by the subsequent git commit/push step.

The badge is consumed in the README via:

https://img.shields.io/endpoint?url=https://testtimescaling.github.io/arxiv_citations.json

Code Reference

Source Location

File .github/scripts/update_arxiv_citations.py
Lines L33-43
Repository testtimescaling.github.io

Signature

    # 生成供 Shields.io 动态徽章使用的 JSON
    badge_data = {
        "schemaVersion": 1,
        "label": "arXiv Citations",
        "message": str(total_citations),
        "color": "blue"
    }

    # 写入 arxiv_citations.json
    with open("arxiv_citations.json", "w") as f:
        json.dump(badge_data, f)

Import

import json

The json module is part of the Python standard library and requires no external installation.

I/O Contract

Inputs

Input Type Description Example
total_citations int The sum of citation counts for all tracked arXiv papers, computed by the preceding fetch step 127

Outputs

Output Type Description Example
arxiv_citations.json JSON file A file in the repository root conforming to the Shields.io endpoint badge schema See below

Example output file content:

{"schemaVersion": 1, "label": "arXiv Citations", "message": "127", "color": "blue"}

Usage Examples

Example 1: Default badge generation (as in the workflow)

import json

total_citations = 127

badge_data = {
    "schemaVersion": 1,
    "label": "arXiv Citations",
    "message": str(total_citations),
    "color": "blue"
}

with open("arxiv_citations.json", "w") as f:
    json.dump(badge_data, f)

Example 2: Custom badge with dynamic color based on count

import json

total_citations = 127

if total_citations >= 100:
    color = "brightgreen"
elif total_citations >= 50:
    color = "green"
elif total_citations >= 10:
    color = "yellow"
else:
    color = "red"

badge_data = {
    "schemaVersion": 1,
    "label": "arXiv Citations",
    "message": str(total_citations),
    "color": color
}

with open("arxiv_citations.json", "w") as f:
    json.dump(badge_data, f)

Example 3: Embedding the badge in a README

![arXiv Citations](https://img.shields.io/endpoint?url=https://testtimescaling.github.io/arxiv_citations.json)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment