{
"info": {
"author": "Thomas Osterland",
"author_email": "highway.ita07@web.de",
"bugtrack_url": null,
"classifiers": [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3"
],
"description": "# Typescript Interface Parser (and to JSON converter)\n\nThe typescript interface parser parses interfaces defined in typescript and outputs a JSON object describing the interfaces.\n\n\n\n## Features\n\n- output to file and to stdio\n- comments are also considered and provided by the JSON representation\n- supports a wide range of typescript syntax (if you find something missing please file a feature request)\n- can be easily integrated in your own program for parsing typescript interfaces\n\n## Table of Contents\n\n1. [Installation](#Installation)\n 1. [Pypi](#Pypi)\n 1. [Manual Installation](#ManualInstallation)\n 1. [Running the Unit Tests](#unittest)\n2. [The JSON Representation](#json)\n 1. [Translation of Attributes](#attributes)\n 1. [Indexed Attributes](#index)\n 1. [Function Attributes](#function)\n\n### MISC\n\nI needed to communicate with a server via RPC from a Python client, but all valid messages were specified in Typescript interfaces. There were a huge number of different messages and I slowly got bored translating the interfaces manually. So I implemented this translator. Hope it will serve you, as well as it served me.\n\n## Installation\n\n### Pypi\n\n### Manual installation\n\nClone the repo and install the requirements with\n`pip install -r requirements.txt`. Than type `python3 ts_interface_parser.py -h` to get an overview of the possible options.\n\n### Running the Unit Tests\n\n```\npython3 -m unittest test.test_parser.TestParser\n```\n\n## The JSON Representation\n\nThe general translation works as follows:\n\n```\n/**\n* \n*/\ninterface extends , {\n : ;\n}\n```\n\nis translated to\n\n```\n{\n \"\" : {\n \"description\" : \"\",\n \"extends\": [\n \"\",\n \"\"\n ]\n \" : {\n \"type\" : [\n \"\"\n ]\n }\n }\n}\n```\n\nThe comment becomes the decsription and potential extensions are provided in the `extends` field. For every specified attribute an object is added referenced by the name of the attribute. Here ``.\n\n### Translation of Attributes\n\nIn the following I give examples of different attribute definitions and how those are translated into JSON.\n\n```\ninterface {\n : | ; // \n /**\n * \n */\n : {\n : \n }\n\n ? : ;\n\n const : ;\n\n readonly : ;\n\n : \"value 1\" | \"value 2\";\n}\n```\n\nis translated to\n\n```\n{\n \"\" : {\n \"\" : {\n \"description\" : \",\n \"type\" : [\n \"type_1\",\n \"type_2\"\n ]\n },\n \"\" : {\n \"description\" : \",\n \"type\": {\n \"\" : {\n \"type\" : [\n \"type_3\"\n ]\n }\n }\n },\n \"\" : {\n \"optional\" : true,\n \"type\" : [\n \"\"\n ]\n },\n \"\" : {\n \"constant\" : true,\n \"type\" : [\n \"\"\n ]\n },\n \"\" : {\n \"readonly\" : true,\n \"type\" : [\n \"\"\n ]\n },\n \"\" : {\n \"type\" : [\n \"'value 1'\",\n \"'value 2'\",\n ]\n }\n }\n}\n```\n\n#### Indexed Attributes\n\n```\ninterface ReadonlyStringArray {\n [index: number]: string;\n}\n```\n\nThe indexed attribute is named with the variable name within the square brackets. The attribute has a field `indexed` which contains the index type and the type the index is refering to.\n\n```\n{\n \"ReadonlyStringArray\": {\n \"index\": {\n \"indexed\": {\n \"type\": [\n \"number\"\n ]\n },\n \"type\": [\n \"string\"\n ]\n }\n }\n}\n```\n\n#### Function Attributes\n\nFunctions are marked by a field `function` in the JSON representation of the function. Thus\n\n```\ninterface ClockInterface {\n setTime(d: Date): void;\n}\n```\n\ntranslates to\n\n```\n{\n \"ClockInterface\": {\n \"setTime\": {\n \"function\": true,\n \"parameters\": {\n \"d\": {\n \"type\": [\n \"Date\"\n ]\n }\n },\n \"type\": [\n \"void\"\n ]\n }\n}\n```\n\nFor anonymous function declarations, as for instance:\n\n```\ninterface SearchFunc{\n (source: string, subString: string): boolean;\n}\n```\n\nThis interface is translated to:\n\n```\n{\n \"SearchFunc\": {\n \"anonymous_function\": {\n \"function\": true,\n \"parameters\": {\n \"source\": {\n \"type\": [\n \"string\"\n ]\n },\n \"subString\": {\n \"type\": [\n \"string\"\n ]\n }\n },\n \"type\": [\n \"boolean\"\n ]\n }\n }\n}\n```\n\n\n",
"description_content_type": "text/markdown",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/highkite/ts_interface_parser",
"keywords": "",
"license": "",
"maintainer": "",
"maintainer_email": "",
"name": "ts-interface-parser",
"package_url": "https://pypi.org/project/ts-interface-parser/",
"platform": "",
"project_url": "https://pypi.org/project/ts-interface-parser/",
"project_urls": {
"Homepage": "https://github.com/highkite/ts_interface_parser"
},
"release_url": "https://pypi.org/project/ts-interface-parser/0.0.1/",
"requires_dist": null,
"requires_python": ">=3.6",
"summary": "The typescript interface parser parses interfaces defined in typescript and outputs a JSON object describing the interfaces.",
"version": "0.0.1"
},
"last_serial": 5976091,
"releases": {
"0.0.1": [
{
"comment_text": "",
"digests": {
"md5": "3d6021254925e8d43006d713ba3f8ea2",
"sha256": "a43c90661f9deb32fba5617c94f42a49a03b662766bfce36e8460c71f6914efe"
},
"downloads": -1,
"filename": "ts_interface_parser-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3d6021254925e8d43006d713ba3f8ea2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5356,
"upload_time": "2019-10-15T10:28:38",
"url": "https://files.pythonhosted.org/packages/29/82/e06ab1d8e9b4fe0fa70b74ce82777be976f42781d8a70737a5b4c6f44534/ts_interface_parser-0.0.1-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "1ae7e4e87ba9840475ccda503f9279b7",
"sha256": "5f4c7b2425441df2204b9e1bcada7ce5ccd7b2b25beba0e39db8e592c22589bd"
},
"downloads": -1,
"filename": "ts_interface_parser-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "1ae7e4e87ba9840475ccda503f9279b7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4494,
"upload_time": "2019-10-15T10:28:41",
"url": "https://files.pythonhosted.org/packages/05/ef/03cb70743e53ca6a47a2be01dc56d3a8ffc6a660b8269643f741b12e81f4/ts_interface_parser-0.0.1.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "3d6021254925e8d43006d713ba3f8ea2",
"sha256": "a43c90661f9deb32fba5617c94f42a49a03b662766bfce36e8460c71f6914efe"
},
"downloads": -1,
"filename": "ts_interface_parser-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3d6021254925e8d43006d713ba3f8ea2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5356,
"upload_time": "2019-10-15T10:28:38",
"url": "https://files.pythonhosted.org/packages/29/82/e06ab1d8e9b4fe0fa70b74ce82777be976f42781d8a70737a5b4c6f44534/ts_interface_parser-0.0.1-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "1ae7e4e87ba9840475ccda503f9279b7",
"sha256": "5f4c7b2425441df2204b9e1bcada7ce5ccd7b2b25beba0e39db8e592c22589bd"
},
"downloads": -1,
"filename": "ts_interface_parser-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "1ae7e4e87ba9840475ccda503f9279b7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4494,
"upload_time": "2019-10-15T10:28:41",
"url": "https://files.pythonhosted.org/packages/05/ef/03cb70743e53ca6a47a2be01dc56d3a8ffc6a660b8269643f741b12e81f4/ts_interface_parser-0.0.1.tar.gz"
}
]
}