srcview

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package srcview provides trusted-byte source inspection and safe project file reads.

Plane: shared

Index

Constants

This section is empty.

Variables

View Source
var ErrNoStructure = errors.New("file does not have a symbol tree")

ErrNoStructure reports a supported read with no targetable symbol structure.

Functions

func IsMarkdown

func IsMarkdown(filename string) bool

IsMarkdown reports whether filename uses Markdown section structure.

Types

type File

type File struct {
	Project string
	Path    string
	Source  []byte
}

File is one safely resolved UTF-8 text file in a registered project.

type Inspector

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

Inspector reads structure from caller-trusted filename and source bytes.

func NewInspector

func NewInspector(filename string, source []byte, depth int) *Inspector

NewInspector returns an inspector over trusted in-memory source.

func (*Inspector) Outline

func (i *Inspector) Outline() (Outline, error)

Outline extracts the file's typed symbol or heading structure.

func (*Inspector) Read

func (i *Inspector) Read(symbolID string, limit int) (ReadResult, error)

Read reads a targetable symbol or section, including an attached code doc comment.

func (*Inspector) ReadContent

func (i *Inspector) ReadContent(symbolID string) (string, error)

ReadContent preserves the established CLI representation of a full symbol or section.

func (*Inspector) RenderTree

func (i *Inspector) RenderTree() (string, error)

RenderTree renders the inspector outline in the existing CLI format.

type Outline

type Outline struct {
	Language string   `json:"language"`
	Title    string   `json:"title,omitempty"`
	Symbols  []Symbol `json:"symbols"`
}

Outline is the typed structure of one source file.

type ProjectService

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

ProjectService resolves project aliases and safely reads repository-relative files.

func NewProjectService

func NewProjectService(projects projectGetter) *ProjectService

NewProjectService creates a project-backed source read service.

func (*ProjectService) ReadFile

func (s *ProjectService) ReadFile(projectAlias, relativePath string) (File, error)

ReadFile resolves an exact alias and repository-relative path without allowing escape.

type ReadResult

type ReadResult struct {
	Content   string
	Start     int
	End       int
	Truncated bool
}

ReadResult is a bounded symbol read with byte offsets into the file.

type Symbol

type Symbol struct {
	ID         string `json:"id"`
	Targetable bool   `json:"targetable"`
	Name       string `json:"name"`
	Kind       string `json:"kind"`
	Parent     string `json:"parent"`
	Level      int    `json:"level"`
	StartByte  int    `json:"start_byte"`
	EndByte    int    `json:"end_byte"`
	StartLine  int    `json:"start_line"`
	EndLine    int    `json:"end_line"`
	HasDoc     bool   `json:"has_doc"`
	// contains filtered or unexported fields
}

Symbol is one source declaration or Markdown section in an outline.

Jump to

Keyboard shortcuts

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