clang

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package clang provides a documentation source adapter that parses C library source code from a local checkout of any C project (glibc, SQLite, OpenSSL, libcurl, etc.). It reads header files (.h) to discover the public API surface and uses tree-sitter for AST parsing plus regex for preprocessor macros.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCheckFactory

func NewCheckFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewCheckFactory creates a Source for the Check unit testing framework.

func NewDPDKFactory

func NewDPDKFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewDPDKFactory creates a Source for the DPDK networking framework.

func NewESPIDFFactory

func NewESPIDFFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewESPIDFFactory creates a Source for the ESP-IDF IoT framework.

func NewFacilioFactory

func NewFacilioFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewFacilioFactory creates a Source for the facil.io web framework.

func NewFreeRTOSFactory

func NewFreeRTOSFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewFreeRTOSFactory creates a Source for the FreeRTOS framework.

func NewGLibFactory

func NewGLibFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewGLibFactory creates a Source for the GLib utility library.

func NewGTKFactory

func NewGTKFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewGTKFactory creates a Source for the GTK GUI framework.

func NewGlibcFactory

func NewGlibcFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewGlibcFactory creates a Source for the GNU C Library.

func NewH2OFactory

func NewH2OFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewH2OFactory creates a Source for the H2O HTTP/2 web server framework.

func NewJanssonFactory

func NewJanssonFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewJanssonFactory creates a Source for the Jansson JSON library.

func NewKoreFactory

func NewKoreFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewKoreFactory creates a Source for the Kore web application framework.

func NewLibcurlFactory

func NewLibcurlFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewLibcurlFactory creates a Source for the libcurl library.

func NewLibpngFactory

func NewLibpngFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewLibpngFactory creates a Source for the libpng library.

func NewLibuvFactory

func NewLibuvFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewLibuvFactory creates a Source for the libuv async I/O library.

func NewLinuxUAPIFactory

func NewLinuxUAPIFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewLinuxUAPIFactory creates a Source for the Linux userspace API headers.

func NewMongooseFactory

func NewMongooseFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewMongooseFactory creates a Source for the Mongoose embedded web framework.

func NewOpenSSLFactory

func NewOpenSSLFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewOpenSSLFactory creates a Source for the OpenSSL library.

func NewSDL2Factory

func NewSDL2Factory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewSDL2Factory creates a Source for the SDL2 multimedia library.

func NewSQLiteFactory

func NewSQLiteFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewSQLiteFactory creates a Source for the SQLite library.

func NewZephyrFactory

func NewZephyrFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewZephyrFactory creates a Source for the Zephyr RTOS framework.

func NewZlibFactory

func NewZlibFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewZlibFactory creates a Source for the zlib compression library.

Types

type CSource

type CSource struct {
	// contains filtered or unexported fields
}

CSource is a documentation source adapter for C libraries. It parses header files to discover public API entities (functions, structs, enums, unions, typedefs, and macros) and uses tree-sitter + regex to extract structured documentation.

func New

func New(repoPath string, cfg Config, opts ...Option) *CSource

New constructs a new CSource pointing at a local checkout of a C library.

func (*CSource) DetectWrapper

func (s *CSource) DetectWrapper(method *source.Method) (bool, string, string)

DetectWrapper analyzes a method's source code for wrapper patterns.

func (*CSource) DiscoverEntities

func (s *CSource) DiscoverEntities(ctx context.Context, fetch source.FetchFunc) ([]string, error)

DiscoverEntities walks the repository header files and returns a sorted list of entity identifiers in the form "filepath#entity_name".

func (*CSource) ID

func (s *CSource) ID() string

ID returns the canonical library ID (e.g., "/c/sqlite").

func (*CSource) Meta

func (s *CSource) Meta() source.LibraryMeta

Meta returns metadata for the library record.

func (*CSource) ParseEntity

func (s *CSource) ParseEntity(ctx context.Context, entityID string, content []byte) (*source.Entity, []string, error)

ParseEntity parses a single entity from a header file identified by entityID. The entityID format is "filepath#entity_name".

func (*CSource) ParseMethod

func (s *CSource) ParseMethod(ctx context.Context, methodID string, content []byte) (*source.Method, error)

ParseMethod parses a function or method from file content.

func (*CSource) ParseSourceCode

func (s *CSource) ParseSourceCode(entityID string, content []byte) (string, error)

ParseSourceCode extracts the source code of a specific entity from file content.

func (*CSource) ResolveWrapperURL

func (s *CSource) ResolveWrapperURL(targetName, targetKind, entitySlug string) string

ResolveWrapperURL constructs the identifier to fetch the wrapped target's source.

type Config

type Config struct {
	// LibraryID is the canonical library identifier (e.g., "/c/sqlite").
	LibraryID string

	// Name is the human-readable library name (e.g., "SQLite").
	Name string

	// Description is a short description of the library.
	Description string

	// SourceURL is the upstream repository URL.
	SourceURL string

	// Version is the library version string.
	Version string

	// TrustScore is the documentation trust score (0.0-1.0).
	TrustScore float64

	// HeaderDirs restricts discovery to these subdirectories (relative to repo root).
	// If empty, defaults to scanning the entire repo for .h files.
	HeaderDirs []string

	// ExcludePatterns are path substrings that skip files during discovery.
	ExcludePatterns []string
}

Config holds the library-specific configuration for a C source adapter.

type Option

type Option func(*CSource)

Option customises a CSource at construction time.

func WithRef

func WithRef(ref string) Option

WithRef sets the git ref (tag or branch) that source-code links point at.

Jump to

Keyboard shortcuts

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