Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,31 @@ with the body elided and gaps marked by `⋮----`.
`Outline(src []byte, filename string) (string, bool)` compresses one file. The
second return is false if the language is not supported.

`Imports(src []byte, filename string) ([]Import, bool)` extracts module imports,
their source-language form, named imports, local aliases, and one-based source
lines. A statement containing both default and named imports returns one value
for each form.

`Refs(src []byte, filename string, receivers []string) ([]Ref, bool)` extracts
direct member accesses on the supplied receiver identifiers. This lets callers
pass the local aliases returned by `Imports` without collecting unrelated
member expressions from the file.

```go
imports, ok := outline.Imports(src, "app.py")
if !ok {
return
}

refs, _ := outline.Refs(src, "app.py", []string{"flask", "f"})
```

For both functions, false means the language is unsupported or parsing did not
complete, including a parse timeout. A true result with an empty slice means
the language is supported but the file contains no matches. Import and
reference extraction currently cover Go, Ruby, Python, JavaScript,
TypeScript/TSX, Rust, PHP, and Elixir.

`Pack(root string, opts Options) (*Result, error)` walks `root`, applies
`.gitignore` plus a built-in ignore list (vendored deps, build output,
lockfiles), skips binaries and oversized files, and outlines what it can.
Expand Down
Loading