Get the FREE Ultimate OpenClaw Setup Guide →

zig-docs

Scanned
npx machina-cli add skill aiskillstore/marketplace/zig-docs --openclaw
Files (1)
SKILL.md
4.9 KB

Zig Documentation Fetching

Instructions

  • Use raw GitHub sources for std lib documentation (most reliable)
  • Use pandoc for language reference from ziglang.org (works for prose content)
  • The std lib HTML docs at ziglang.org are JavaScript-rendered and return empty content; avoid them
  • Zig source files contain doc comments (//! for module docs, /// for item docs) that serve as authoritative documentation

Quick Reference

Fetch Standard Library Source (Recommended)

Standard library modules are self-documenting. Fetch source directly:

# Module source with doc comments
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/<module>.zig"

# Common modules:
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/log.zig"
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/mem.zig"
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/fs.zig"
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/heap.zig"
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/debug.zig"
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/testing.zig"

Fetch Allocator Interface

curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/mem/Allocator.zig"

Fetch Language Reference (Prose)

# Full language reference (large, ~500KB of text)
pandoc -f html -t plain "https://ziglang.org/documentation/master/"

# Pipe to head for specific sections
pandoc -f html -t plain "https://ziglang.org/documentation/master/" | head -200

List Standard Library Contents

# List all std lib modules via GitHub API
curl -sL "https://api.github.com/repos/ziglang/zig/contents/lib/std" | jq -r '.[].name'

# List subdirectory contents
curl -sL "https://api.github.com/repos/ziglang/zig/contents/lib/std/mem" | jq -r '.[].name'

Fetch zig.guide Content

# Landing page and navigation
pandoc -f html -t plain "https://zig.guide/"

Documentation Sources

SourceURL PatternNotes
Std lib sourceraw.githubusercontent.com/ziglang/zig/master/lib/std/<path>Most reliable; includes doc comments
Language referenceziglang.org/documentation/master/Use pandoc; prose content
zig.guidezig.guide/Beginner-friendly; use pandoc
GitHub APIapi.github.com/repos/ziglang/zig/contents/lib/stdList directory contents

Common Module Paths

ModulePath
Allocatorlib/std/mem/Allocator.zig
ArrayListlib/std/array_list.zig
HashMaplib/std/hash_map.zig
StringHashMaplib/std/hash/map.zig
File Systemlib/std/fs.zig
Filelib/std/fs/File.zig
IOlib/std/Io.zig
Logginglib/std/log.zig
Testinglib/std/testing.zig
Debuglib/std/debug.zig
Heaplib/std/heap.zig
Build Systemlib/std/Build.zig
JSONlib/std/json.zig
HTTPlib/std/http.zig
Threadlib/std/Thread.zig
Processlib/std/process.zig

Version-Specific Documentation

Replace master with version tag for stable releases:

# 0.14.0 release
curl -sL "https://raw.githubusercontent.com/ziglang/zig/0.14.0/lib/std/log.zig"

# Language reference for specific version
pandoc -f html -t plain "https://ziglang.org/documentation/0.14.0/"

Searching Documentation

Search for specific function/type in std lib

# Search for function name across std lib
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/<module>.zig" | grep -A5 "pub fn <name>"

# Example: find allocator.create
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/mem/Allocator.zig" | grep -A10 "pub fn create"

Extract doc comments

# Module-level docs (//!)
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/log.zig" | grep "^//!"

# Function/type docs (///)
curl -sL "https://raw.githubusercontent.com/ziglang/zig/master/lib/std/mem/Allocator.zig" | grep -B1 "pub fn" | grep "///"

Troubleshooting

Empty content from ziglang.org/documentation/master/std/:

  • The std lib HTML docs are JavaScript-rendered; use raw GitHub instead

pandoc fails:

  • Some pages require JavaScript; fall back to curl + raw GitHub
  • Check URL is correct (no trailing slash issues)

Rate limiting on GitHub API:

  • Use raw.githubusercontent.com URLs directly instead of API
  • Cache frequently accessed content locally

References

Source

git clone https://github.com/aiskillstore/marketplace/blob/main/skills/0xbigboss/zig-docs/SKILL.mdView on GitHub

Overview

zig-docs retrieves Zig language and standard library documentation through the CLI. It prioritizes raw std lib sources (with doc comments) and uses pandoc to render the official language reference. It avoids JavaScript-rendered std lib HTML docs because they often return empty content.

How This Skill Works

Standard library docs come from raw Zig sources on GitHub, which include doc comments as authoritative documentation. For language reference, zig-docs uses pandoc to convert ziglang.org HTML content into plain text, optionally targeting a specific version. By following these sources, you get accurate API details and prose content not covered by zig-best-practices.

When to Use It

  • When you need Zig std lib API details and function signatures from real module sources (mem, log, fs, etc).
  • When the Zig language reference prose is required and not covered by zig-best-practices.
  • When you want authoritative docs from Zig source comments (//! at module level, /// for items).
  • When exploring or validating available std lib modules via the GitHub contents API.
  • When needing version-specific documentation for a given Zig release (e.g., 0.14.0).

Quick Start

  1. Step 1: Fetch a std lib module source: curl -sL \"https://raw.githubusercontent.com/ziglang/zig/master/lib/std/<module>.zig\"
  2. Step 2: Fetch language reference content: pandoc -f html -t plain \"https://ziglang.org/documentation/master/\"
  3. Step 3: Optional: fetch zig.guide content with pandoc: pandoc -f html -t plain \"https://zig.guide/\"

Best Practices

  • Prefer raw std lib sources (lib/std/*.zig) for authoritative docs.
  • Use pandoc to render language reference content from ziglang.org instead of relying on HTML layer.
  • Avoid relying on the JS-rendered std lib HTML docs on ziglang.org.
  • Cross-check doc comments (//! and ///) against generated docs for accuracy.
  • Pin to a specific Zig version when fetching docs to ensure compatibility.

Example Use Cases

  • Fetch std lib module mem.zig and review its doc comments.
  • Download lib/std/fs.zig to inspect file system APIs.
  • Render the language reference for master via pandoc and skim sections with head.
  • List std lib modules via the GitHub API and open Allocator.zig docs.
  • Compare docs from source comments with a language reference excerpt for the same concept.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers