Metadata-Version: 2.4
Name: codesigs
Version: 0.0.1
Summary: Extract function and method signatures from source code across multiple languages.
Home-page: https://github.com/AnswerDotAI/codesigs
Author: Jeremy Howard
Author-email: github@jhoward.fastmail.fm
License: Apache-2.0
Keywords: nbdev jupyter notebook python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastcore
Requires-Dist: ast-grep-py
Provides-Extra: dev
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# codesigs


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## About `codesigs`

`codesigs` extracts function and method signatures from source code
across over a dozen programming languages. It uses
[ast-grep](https://ast-grep.github.io/) for most languages and Python’s
built-in `ast` module for Python files, providing accurate syntax-aware
parsing rather than brittle regex matching.

This is useful for:

- **Documentation generation** - quickly summarize the public API of a
  codebase
- **Code search and navigation** - find functions by signature pattern
- **LLM context preparation** - provide compact API summaries to
  language models without including full implementations
- **Codebase analysis** - understand the structure of unfamiliar
  projects

## Installation

Install latest from [pypi](https://pypi.org/project/codesigs/)

``` sh
$ pip install codesigs
```

## How to use

Pass source code to a language-specific function to get a list of
signatures:

``` python
sigs = py_sigs("""
def greet(name, age=10):
    "Say hello to someone"
    return f"Hello {name}, you are {age}"

class Calculator:
    def add(self, a, b):
        return a + b
""")
for o in sigs: print(o)
```

    def greet(name, age=10):
        "Say hello to someone" ...
    class Calculator: ...
        def add(self, a, b): ...

Use
[`ext_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#ext_sigs)
when you have source code and know the file extension:

``` python
ext_sigs("function greet(name) { return `Hello ${name}`; }", ".js")
```

    ['function greet(name) {...}']

Or use
[`file_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#file_sigs)
to read and extract signatures from a file in one step:

``` python
file_sigs('../codesigs/core.py')[:3]
```

    ['def get_docstring(node, lines):\n    "Get docstring from source lines if present" ...',
     'def _node_sig(node, lines): ...',
     'def py_sigs(src):\n    "Extract class/function/method signatures from Python source" ...']

The package supports Python, JavaScript/TypeScript, Java, Rust, C#, CSS,
Go, Ruby, PHP, Kotlin, Swift, and Lua. Each language has a dedicated
function
(e.g. [`js_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#js_sigs),
[`rust_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#rust_sigs)),
or use
[`ext_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#ext_sigs)/[`file_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#file_sigs)
which auto-detect from the extension.
