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.1.tar.gz (10.4 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.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codesigs-0.0.1.tar.gz
  • Upload date:
  • Size: 10.4 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.1.tar.gz
Algorithm Hash digest
SHA256 490a0cad27b83e8d7b288faa841a0fee37bc715e32d43dd203b24a3897534e25
MD5 a72d99a3fab5f1effcc7d55c2db94d52
BLAKE2b-256 bb1516a953b7d77c5d0f10ce2811890a54007e962ba7f0e00f1cca379df17b62

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codesigs-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7753f626b10a5bb2defe5626b9f90d6644618c88166cf8a1b2dc1d5e007e7484
MD5 37343d7ef04d84e20e92e440571d7a6e
BLAKE2b-256 3570783170a8c1e093ef407a306b3a9a326076fc3044f993147cde49e6374938

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