{ "info": { "author": "Mozilla Services and contributors", "author_email": "services-dev@mozilla.org", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python" ], "description": "cornice_sphinx\n==============\n\n*Cornice extension to generate Sphinx doc*\n\nMaintaining documentation while the code is evolving is painful.\nAvoiding information duplication is also quite a challenge.\n\nCornice tries to reduce a bit the pain by providing a Sphinx\n(http://sphinx.pocoo.org/) directive that scans the web\nservices and build the documentation using:\n\n- the description provided when a Service instance is created\n- the docstrings of all functions involved in creating the response:\n the web services function itself and the validators.\n\nThe assumption made is that maintaining those docstrings while\nworking on the code is easier.\n\n\nActivate the extension\n----------------------\n\nTo activate Cornice's directive, you must include it in your\nSphinx project :file:`conf.py` file::\n\n import cornice\n\n sys.path.insert(0, os.path.abspath(cornice.__file__))\n extensions = ['cornice_sphinx']\n\nOf course this may vary if you have other extensions.\n\n\nThe service directive\n---------------------\n\nCornice provides a **cornice-autodoc** directive you can use to\ninject the Web Services documentation into Sphinx.\n\nThe directive has the following options:\n\n- **modules**: a comma-separated list of the python modules that contain\n Cornice Web services. Cornice will scan it and look for the services.\n- **app**: set the path to you app needed for imperative registering services.\n- **services**: a comma-separated list of services, as you named them when\n using the cornice `Service` directive. **optional**\n- **service**: if you have only one name, then you can use `service` rather\n than `services`. **optional**\n- **ignore**: a comma separated list of services names to ignore. **optional**\n\n **module** or **app** are **mandatory**\n\nYou can use info fields (see\n`Info field lists `_)\nin your functions, methods and validators.\n\n.. note::\n This directive used to be named \"services\" and had been renamed for\n something more consistant with the Sphinx ecosystem.\n\nFull example\n------------\n\nLet's say you have a **quote** project with a single service where you\ncan **POST** and **GET** a quote.\n\nThe service makes sure the quote starts with a majuscule and ends with\na dot !\n\nHere's the **full** declarative app::\n\n from cornice import Service\n from pyramid.config import Configurator\n import string\n\n desc = \"\"\"\\\n Service that maintains a quote.\n \"\"\"\n\n quote = Service(name='quote', path='/quote', description=desc)\n\n\n def check_quote(request):\n \"\"\"Makes sure the quote starts with a majuscule and ends with a dot\"\"\"\n quote = request.body\n if quote[0] not in string.ascii_uppercase:\n request.errors.add('body', 'quote', 'Does not start with a majuscule')\n\n if quote[-1] not in ('.', '?', '!'):\n request.errors.add('body', 'quote', 'Does not end properly')\n\n if len(request.errors) == 0:\n request.validated['quote'] = quote\n\n\n _quote = {}\n _quote['default'] = \"Not set, yet !\"\n\n\n @quote.get()\n def get_quote(request):\n \"\"\"Returns the quote\"\"\"\n return _quote['default']\n\n\n @quote.post(validators=check_quote)\n def post_quote(request):\n \"\"\"Update the quote\"\"\"\n _quote['default'] = request.validated['quote']\n\n\n def main(global_config, **settings):\n config = Configurator(settings={})\n config.include(\"cornice\")\n config.scan(\"coolapp\")\n return config.make_wsgi_app()\n\n if __name__ == '__main__':\n from wsgiref.simple_server import make_server\n app = main({})\n httpd = make_server('', 6543, app)\n print(\"Listening on port 6543....\")\n httpd.serve_forever()\n\n\nAnd here's the **full** Sphinx doc example::\n\n Welcome to coolapp's documentation!\n ===================================\n\n My **Cool** app provides a way to send cool quotes to the server !\n\n .. cornice-autodoc::\n :modules: coolapp\n :service: quote\n\nHere's the **full** imperative app::\n\n from cornice import Service\n from pyramid.config import Configurator\n import string\n\n\n def check_quote(request):\n \"\"\"Makes sure the quote starts with a majuscule and ends with a dot\"\"\"\n quote = request.body\n if quote[0] not in string.ascii_uppercase:\n request.errors.add('body', 'quote', 'Does not start with a majuscule')\n\n if quote[-1] not in ('.', '?', '!'):\n request.errors.add('body', 'quote', 'Does not end properly')\n\n if len(request.errors) == 0:\n request.validated['quote'] = quote\n\n\n _quote = {}\n _quote['default'] = \"Not set, yet !\"\n\n\n def get_quote(request):\n \"\"\"Returns the quote\"\"\"\n return _quote['default']\n\n\n def post_quote(request):\n \"\"\"Update the quote\"\"\"\n _quote['default'] = request.validated['quote']\n\n\n def main(global_config, **settings):\n config = Configurator(settings={})\n config.include(\"cornice\")\n desc = \"Service that maintains a quote.\"\n quote = Service(name='quote', path='/quote', description=desc)\n quote.add_view(\"GET\", get_quote)\n quote.add_view(\"POST\", post_quote, validators=check_quote)\n config.add_cornice_service(quote)\n return config.make_wsgi_app()\n\n if __name__ == '__main__':\n from wsgiref.simple_server import make_server\n app = main({})\n httpd = make_server('', 6543, app)\n print(\"Listening on port 6543....\")\n httpd.serve_forever()\n\nClient calls::\n\n $ curl -X POST http://localhost:6543/quote -d Hansolohat.\n null\n $ curl -X GET http://localhost:6543/quote\n \"Hansolohat.\"\n\nAnd here's the **full** Sphinx doc example::\n\n Welcome to coolapp's documentation!\n ===================================\n\n My **Cool** app provides a way to send cool quotes to the server !\n\n .. cornice-autodoc::\n :app: coolapp\n :service: quote\n\n\nThe resulting doc is:\n\n.. image:: cornice.png\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Cornices/cornice.ext.sphinx", "keywords": "web services", "license": "Apache License (2.0)", "maintainer": "", "maintainer_email": "", "name": "cornice_sphinx", "package_url": "https://pypi.org/project/cornice_sphinx/", "platform": "", "project_url": "https://pypi.org/project/cornice_sphinx/", "project_urls": { "Homepage": "https://github.com/Cornices/cornice.ext.sphinx" }, "release_url": "https://pypi.org/project/cornice_sphinx/0.3/", "requires_dist": [ "Sphinx", "cornice", "docutils" ], "requires_python": "", "summary": "Generate Sphinx documentation from a Cornice application", "version": "0.3" }, "last_serial": 4266231, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "54405f6f57f350a05e89f57c91b5ee41", "sha256": "8ec64a517144bf3bb69741204e498a4d5202c6480d0f2616e14547343454f8ce" }, "downloads": -1, "filename": "cornice_sphinx-0.1.tar.gz", "has_sig": false, "md5_digest": "54405f6f57f350a05e89f57c91b5ee41", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11454, "upload_time": "2016-10-20T09:33:31", "url": "https://files.pythonhosted.org/packages/56/54/2842c53d657a518069578a35d2757c0e7d768eba8b54b009e5c8b1cefa40/cornice_sphinx-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "e7d6e4c651482df0e20ba2497e2a5868", "sha256": "cd4e0f685ace1e83c9bd39407e2f1c4221e702717d04a47d00538e7c70d2db5a" }, "downloads": -1, "filename": "cornice_sphinx-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "e7d6e4c651482df0e20ba2497e2a5868", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11048, "upload_time": "2017-10-30T14:18:33", "url": "https://files.pythonhosted.org/packages/31/e6/c7c6556ebac4d10813e5e0216438da94d76e30ffa82fee11035319c83bb5/cornice_sphinx-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a14bae049a3d9ef6ca92c7b655c4fdbc", "sha256": "25847351ac503403733730182affbc19294b8c54d22e1a29a8cdbe0d0e95d6d1" }, "downloads": -1, "filename": "cornice_sphinx-0.2.tar.gz", "has_sig": false, "md5_digest": "a14bae049a3d9ef6ca92c7b655c4fdbc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11712, "upload_time": "2017-10-30T14:18:36", "url": "https://files.pythonhosted.org/packages/20/fb/71709eeeae8e10f6dfba98c5a3280cf30ef2d29243a9743ef4557550aa8e/cornice_sphinx-0.2.tar.gz" } ], "0.2.dev0": [], "0.3": [ { "comment_text": "", "digests": { "md5": "b2dc4b3af03a8730a3165d1bc37fb4fa", "sha256": "09ac165c681fb1e97ad188438c16deb2d74eb3303886449b8b608c9f479bf3cd" }, "downloads": -1, "filename": "cornice_sphinx-0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "b2dc4b3af03a8730a3165d1bc37fb4fa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11228, "upload_time": "2017-12-06T17:48:11", "url": "https://files.pythonhosted.org/packages/ea/44/04c277c8bd977162a837a0b0e4c33f747d7e86a09cfd8463cc7eb96ddd24/cornice_sphinx-0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "22b5a7c52011a660ddcf3f009699a2f1", "sha256": "77d2d5090670e1703729fb6ff5a8e75d2a785cec25c342f0c6e2d440f216f97b" }, "downloads": -1, "filename": "cornice_sphinx-0.3.tar.gz", "has_sig": false, "md5_digest": "22b5a7c52011a660ddcf3f009699a2f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11841, "upload_time": "2017-12-06T17:48:13", "url": "https://files.pythonhosted.org/packages/1a/3f/2181824bb8750713798a61e9b98599d0fa0153228cfc18065b80394a187e/cornice_sphinx-0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b2dc4b3af03a8730a3165d1bc37fb4fa", "sha256": "09ac165c681fb1e97ad188438c16deb2d74eb3303886449b8b608c9f479bf3cd" }, "downloads": -1, "filename": "cornice_sphinx-0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "b2dc4b3af03a8730a3165d1bc37fb4fa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11228, "upload_time": "2017-12-06T17:48:11", "url": "https://files.pythonhosted.org/packages/ea/44/04c277c8bd977162a837a0b0e4c33f747d7e86a09cfd8463cc7eb96ddd24/cornice_sphinx-0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "22b5a7c52011a660ddcf3f009699a2f1", "sha256": "77d2d5090670e1703729fb6ff5a8e75d2a785cec25c342f0c6e2d440f216f97b" }, "downloads": -1, "filename": "cornice_sphinx-0.3.tar.gz", "has_sig": false, "md5_digest": "22b5a7c52011a660ddcf3f009699a2f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11841, "upload_time": "2017-12-06T17:48:13", "url": "https://files.pythonhosted.org/packages/1a/3f/2181824bb8750713798a61e9b98599d0fa0153228cfc18065b80394a187e/cornice_sphinx-0.3.tar.gz" } ] }