Skip to main content

Extract function and method signatures from source code across multiple languages.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codesigs-0.0.2.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codesigs-0.0.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file codesigs-0.0.2.tar.gz.

File metadata

  • Download URL: codesigs-0.0.2.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for codesigs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 806126911cf1a3cb6142c1fe29b56ad2f8d228c38294b37433cb253383273084
MD5 7375783b19f6491e4ac2daceaa148615
BLAKE2b-256 031512054e016198529d5d3547d3b21273433a74256672b30f4bf48d8cbba093

See more details on using hashes here.

File details

Details for the file codesigs-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: codesigs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for codesigs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 84414c06db5dd4dc5dd0828be0bde3dd683446041846df4a09fca072ed7a8350
MD5 f8d54f369480bfc315f943fafc4be673
BLAKE2b-256 49c12c028485775d120e14e97547de0591f7adb2a157f7eae739fe2c54655439

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page