Skip to content

Commit bd87750

Browse files
authored
Merge pull request #13 add setup.py adn fix imports
2 parents e8417b7 + 92d0924 commit bd87750

File tree

6 files changed

+52
-13
lines changed

6 files changed

+52
-13
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
# hydra-python-core
22
This library provides the core functions to implement Hydra Official Specification in Python.
33

4+
Currently the library mainly consists of 2 modules `doc_writer` and `doc_maker` which help hydrus generalise a lot of things.
45

5-
*Porting out from hydrus the hydraspecs directory*
6+
-> `doc_writer` creates a new API Documentation as well as a `HydraDoc` object while,
7+
-> `doc_maker` uses an existing API Documentation to create a `HydraDoc` object c`
8+
9+
10+
11+
### Installation
12+
13+
To install the library:
14+
15+
```bash
16+
pip install git+https://github.com/HTTP-APIs/hydra-python-core.git#egg=hydra_python_core
17+
```
18+
19+
**Note :-** If using hydrus, the library doesn't need to be installed separately as it is already a part of `requirements.txt` for hydrus.
620

21+
22+
23+
### Usage
24+
25+
To import the modules:
26+
27+
```python
28+
from hydra_python_core import doc_writer
29+
from hydra_python_core import doc_maker
30+
```
31+
32+
*Porting out from hydrus the hydraspecs directory*

hydra_python_core/doc_maker.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
'''Contsructor to take a Python dict containing an API Documentation and
2-
create a HydraDoc object for it'''
1+
"""Contsructor to take a Python dict containing an API Documentation and
2+
create a HydraDoc object for it
3+
"""
34
import re
45
import json
5-
from hydrus.samples.doc_writer_sample import api_doc as sample_document
6-
from hydrus.hydraspec.doc_writer import HydraDoc, HydraClass, HydraClassProp, HydraClassOp
7-
from hydrus.hydraspec.doc_writer import HydraStatus
6+
from hydra_python_core.doc_writer import HydraDoc, HydraClass, HydraClassProp, HydraClassOp
7+
from hydra_python_core.doc_writer import HydraStatus
88
from typing import Any, Dict, Match, Optional, Tuple, Union
99

1010

11-
def error_mapping(body: str = None) -> str:
11+
def error_mapping(body: str=None) -> str:
1212
"""Function returns starting error message based on its body type.
1313
:param body: Params type for error message
1414
:return string: Error message for input key
@@ -357,8 +357,3 @@ def create_status(possible_status: Dict[str, Any]) -> HydraStatus:
357357
status = HydraStatus(result["statusCode"],
358358
result["title"], result["description"])
359359
return status
360-
361-
362-
if __name__ == "__main__":
363-
api_doc = create_doc(sample_document.generate())
364-
print(json.dumps(api_doc.generate(), indent=4, sort_keys=True))

samples/__init__.py

Whitespace-only changes.

samples/cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import json
2+
3+
if __name__ == "__main__":
4+
api_doc = create_doc(sample_document.generate())
5+
print(json.dumps(api_doc.generate(), indent=4, sort_keys=True))

samples/doc_writer_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Sample to create Hydra APIDocumentation using doc_writer."""
22

3-
from hydrus.hydraspec.doc_writer import HydraDoc, HydraClass, HydraClassProp, HydraClassOp
3+
from hydra_python_core.doc_writer import HydraDoc, HydraClass, HydraClassProp, HydraClassOp
44
from typing import Any, Dict, Union
55

66
# Creating the HydraDoc object, this is the primary class for the Doc

setup.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(
4+
name='hydra_python_core',
5+
version='0.1',
6+
packages=find_packages(),
7+
license='MIT',
8+
description='Core functions for Hydrus',
9+
long_description=open('README.md').read(),
10+
long_description_content_type="text/markdown",
11+
url='https://github.com/HTTP-APIs/hydra-python-core',
12+
zip_safe=False
13+
)

0 commit comments

Comments
 (0)