Skip to main content

codesigs

About codesigs

codesigs extracts function and method signatures from source code across over a dozen programming languages. It uses ast-grep 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

$ pip install codesigs

How to use

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

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 when you have source code and know the file extension:

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

Or use file_sigs to read and extract signatures from a file in one step:

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, rust_sigs), or use ext_sigs/file_sigs which auto-detect from the extension.

Metadata

Release files for codesigs 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codesigs 0.0.3
File Size Uploaded
codesigs-0.0.3.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codesigs 0.0.3
File Interpreter ABI Platform
codesigs-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 18.9 kB

Release files / codesigs-0.0.3.tar.gz

Download URL codesigs-0.0.3.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6786f9652ffdd6ea481697fb7baecd5b44ed6d5bf52fda529b76e5c8ee79d8d4
BLAKE2b-256 checksum
How to use checksums
92de7a3c6b900594944dbc89b7cce1c6d58a5fac56971171405f4749f757025d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / codesigs-0.0.3-py3-none-any.whl

Download URL codesigs-0.0.3-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83591fc5e317609ed42b776e52fcd8fc3fdf8ffca5e6e92c5225358ac0ee62b8
BLAKE2b-256 checksum
How to use checksums
93812d1049c2dea9ba328dac97346e7a32a326fdb2fdf2b5d95db46688d6784a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page