https://github.com/legovaer/jsonnet-docblock-parser
Simple, powerfull jsonnet docblock parser that returns a JSON representation to work with
https://github.com/legovaer/jsonnet-docblock-parser
Last synced: 7 months ago
JSON representation
Simple, powerfull jsonnet docblock parser that returns a JSON representation to work with
- Host: GitHub
- URL: https://github.com/legovaer/jsonnet-docblock-parser
- Owner: legovaer
- License: mit
- Created: 2020-03-05T21:21:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-03T08:36:26.000Z (almost 5 years ago)
- Last Synced: 2024-12-04T16:08:02.703Z (7 months ago)
- Language: Python
- Size: 23.4 KB
- Stars: 10
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Jsonnet Docblock Parser
JDP is a simple, powerfull jsonnet docblock parser that returns a JSON representation to work with.
[](https://travis-ci.com/legovaer/jsonnet-docblock-parser)
[](https://pypi.python.org/pypi/jsonnet_docblock_parser/)
[](https://pypi.python.org/pypi/jsonnet_docblock_parser/)
[](https://pypi.python.org/pypi/jsonnet_docblock_parser/)
[](https://pypi.python.org/pypi/jsonnet_docblock_parser/)This parser will extract docblocks from your `.jsonnet` or `.libsonnet` files. This package
includes a generator that allows you to output the parsed information into JSON format.The parser assumes that the documentation inside these files is written in a syntax that is
similar to JavaScript, Java and many C++ scripts:```
{
/**
* Returns whether the string a is prefixed by the string b.
*
* @param a The input string.
* @param b The prefix.
* @return true if string a is prefixed by the string b or false otherwise.
*/
startsWith(a, b):
if std.length(a) < std.length(b) then
false
else
std.substr(a, 0, std.length(b)) == b,
}
```## Installation
You can install the tool via pip:
```bash
pip install jsonnet-docblock-parser
```## Module Usage
```python
#!/usr/bin/env python
# encoding: utf-8from jsonnet_docblock_parser import parseFile, Generator
# Load a jsonnet or libsonnet file.
TEST_FILE = "some.jsonnet"# Parse the file.
docblocks = parseFile(TEST_FILE)# Load the generator.
generator = Generator()# Parse Json based on the results.
json = generator.parse_json(results)# Print the json
print(json)
```## CLI Usage
```bash
jdp --file some.jsonnet
```## Development
### Testing
```bash
pytest
```### PyLint
```bash
pylint jsonnet_docblock_parser
```### Deploying to PyPi
```bash
python3 setup.py sdist
twine upload dist/*
```## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.