topics

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package topics owns the M4 "topics" plugin. It scrapes the user's starred-topics page via chromedp because the GitHub API does not expose the dataset directly.

Contracts: specs/004-m4-github-plugins/contracts/plugin-p3-heavy.md §3 Data model: specs/004-m4-github-plugins/data-model.md E-023

The runtime keeps the chromedp surface behind a small Navigator interface so non-chromedp tests can exercise the skipped/short-circuit paths without launching chromium. The chromedp-tagged tests substitute the production Navigator backed by *render.Browser.

Index

Constants

View Source
const Name = "topics"

Name is the canonical plugin slug.

View Source
const NavigatorKey = "_test_topics_navigator"

NavigatorKey is the inputs map slot tests use to inject a fake Navigator. Production code never sets this — the plugin falls back to pc.Render.

Variables

View Source
var Plugin plugins.Plugin = &topicsPlugin{}

Plugin is the singleton registered with the global plugin registry.

Functions

func Partial

Partial renders the classic SVG fragment for the topics plugin. DOM contract (partial-classic-m4.md §5): emits one <g class="topic"> containing a <text class="topic-name"> per topic.

Types

type Navigator interface {
	Fetch(ctx context.Context, url string) ([]Topic, error)
}

Navigator abstracts the chromedp-backed page scrape so non-chromedp tests can inject a fake. Production code uses browserNavigator backed by *render.Browser.

func NewBrowserNavigator

func NewBrowserNavigator(b *render.Browser) Navigator

NewBrowserNavigator returns a production Navigator. Exposed for chromedp-tagged tests that want to drive the real scrape path against a local fixture server.

type Result

type Result struct {
	Skipped       bool    `json:"skipped,omitempty"`
	SkippedReason string  `json:"-"`
	List          []Topic `json:"list"`
	Mode          string  `json:"mode"`
	Limit         int     `json:"limit"`
	Sort          string  `json:"sort"`
}

Result is the JSON payload published under data.Plugins["topics"]. Field set mirrors data-model E-023.

func (*Result) IsSkipped

func (r *Result) IsSkipped() bool

IsSkipped lets the classic dispatcher detect the skipped path.

type Topic

type Topic struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
	URL         string `json:"url"`
	// StarredAt is opaque metadata used only for sorting when the user
	// requested sort="starred-at". Not part of the public JSON shape;
	// upstream does not expose it.
	StarredAt string `json:"-"`
}

Topic mirrors one entry in the starred-topics list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL