langutil

package
v1.23.4 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package langutil provides shared language-aware helpers used across go-code packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsExportedForDoc added in v1.22.0

func IsExportedForDoc(name, language string, isPublic bool) bool

IsExportedForDoc reports whether a symbol is considered exported for doc-coverage purposes, using language-appropriate rules. The logic mirrors isExportedSymbol in internal/compare/apisurf.go, extended with the IsPublic early-return for languages that carry an explicit visibility flag.

  • IsPublic=true always wins — covers explicit "pub fn" (Rust), "def" with __all__ (Python), "public:" (C++), and any other language where the parser sets the flag.
  • Go, Java, C#: uppercase-first-rune convention.
  • JavaScript, TypeScript, Rust, Python, and all others: any non-underscore name is exported (matches the non-Go branch in apisurf.isExportedSymbol).

func IsTestFile

func IsTestFile(path string) bool

IsTestFile returns true if the path looks like a test file based on suffix, prefix, infix, or containing directory.

func RelPath

func RelPath(abs, root string) string

RelPath returns the relative path from root to abs. Falls back to the absolute path on error.

func TestStem

func TestStem(path string) (stem string, ok bool)

TestStem extracts the logical stem from an infix-based test file path (e.g. "Button.test.ts" → "Button", true; "Modal.spec.svelte" → "Modal", true). It uses the first occurrence of ".test." or ".spec." in the file base-name. Returns ("", false) if the path does not contain a recognised infix or if the stem before the infix is empty (e.g. ".test.ts"). Detection is case-sensitive; lowercase the path first if case-insensitive matching is needed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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