A library for parsing and composing JSDoc strings
Project description
JSDoc Parser
A Python library for parsing and composing JSDoc strings.
Installation
pip install jsdoc-parser
Usage
from jsdoc_parser import parse_jsdoc, compose_jsdoc
# Parse a JSDoc string into an object
jsdoc_str = """/**
* Calculates the sum of two numbers
* @param {number} a - First number
* @param {number} b - Second number
* @returns {number} The sum of a and b
*/"""
parsed = parse_jsdoc(jsdoc_str)
print(parsed)
# Output: {'description': 'Calculates the sum of two numbers', 'params': [{'name': 'a', 'type': 'number', 'description': 'First number'}, {'name': 'b', 'type': 'number', 'description': 'Second number'}], 'returns': {'type': 'number', 'description': 'The sum of a and b'}}
# Modify the parsed object
parsed['params'][0]['description'] = 'Modified description'
# Compose the modified object back to a JSDoc string
new_jsdoc = compose_jsdoc(parsed)
print(new_jsdoc)
Features
- Parse JSDoc strings into structured Python objects
- Compose JSDoc objects back into properly formatted JSDoc strings
- Support for various JSDoc tags: @param, @returns, @throws, etc.
- Easy manipulation of JSDoc components
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsdoc_parser-0.1.1.tar.gz
(12.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsdoc_parser-0.1.1.tar.gz.
File metadata
- Download URL: jsdoc_parser-0.1.1.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71581ef01817bbc38989fc43b27b61a45e64730742840b24cbf19bf9c60803e7
|
|
| MD5 |
d375aa00f77feebeb87405550ea43ee6
|
|
| BLAKE2b-256 |
57d8746f341ed515850445476846aebcd8711a87d36987a6e70f216774ea3467
|
File details
Details for the file jsdoc_parser-0.1.1-py3-none-any.whl.
File metadata
- Download URL: jsdoc_parser-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0fff5c0d884422f2a3f5df822e82bcb64e92e86796df3ac54aab8a97648b095
|
|
| MD5 |
c7082fa4259075c88ecda6199f30adec
|
|
| BLAKE2b-256 |
d3d11f6561db6677c9383c9c91bdce3963276e8cad080ae70f0c4e468b81576f
|