From 940ab9d762079241b0ac2c65efb781863cef7c80 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 11 Oct 2018 13:57:55 -0400 Subject: [PATCH] better --- Pipfile | 4 + Pipfile.lock | 62 ++++++- docs/source/_static/custom.css | 7 + docs/source/_static/konami.js | 151 ++++++++++++++++++ .../source/_static/responder.png | Bin docs/source/_templates/hacks.html | 138 ++++++++++++++++ docs/source/_templates/sidebarintro.html | 34 ++++ docs/source/_templates/sidebarlogo.html | 34 ++++ docs/source/conf.py | 99 +++++++----- responder/api.py | 4 - 10 files changed, 492 insertions(+), 41 deletions(-) create mode 100644 docs/source/_static/custom.css create mode 100644 docs/source/_static/konami.js rename ext/Artboard 1@2x.png => docs/source/_static/responder.png (100%) create mode 100644 docs/source/_templates/hacks.html create mode 100644 docs/source/_templates/sidebarintro.html create mode 100644 docs/source/_templates/sidebarlogo.html diff --git a/Pipfile b/Pipfile index 99e90c9..24d1ca5 100644 --- a/Pipfile +++ b/Pipfile @@ -14,6 +14,10 @@ black = "*" twine = "*" flask = "*" sphinx = "*" +mkdocs = "*" +pymdown-extensions = "*" +pygments = "*" +pygments-github-lexers = "*" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index 683f75c..0e6c21e 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "76d2978ee90d2c028b13c9a5abdd2371d74d514045d50fb9b92aec44e72054b3" + "sha256": "82bec12cc904cea52a7b44eed97ca76162a2a4b39341cd6d7f920852fb9d997e" }, "pipfile-spec": 6, "requires": { @@ -420,6 +420,20 @@ ], "version": "==2.10" }, + "livereload": { + "hashes": [ + "sha256:583179dc8d49b040a9da79bd33de59e160d2a8802b939e304eb359a4419f6498", + "sha256:dd4469a8f5a6833576e9f5433f1439c306de15dbbfeceabd32479b1123380fa5" + ], + "version": "==2.5.2" + }, + "markdown": { + "hashes": [ + "sha256:c00429bd503a47ec88d5e30a751e147dcb4c6889663cd3e2ba0afe858e009baa", + "sha256:d02e0f9b04c500cde6637c11ad7c72671f359b87b9fe924b2383649d8841db7c" + ], + "version": "==3.0.1" + }, "markupsafe": { "hashes": [ "sha256:a6be69091dac236ea9c6bc7d012beab42010fa914c459791d627dad4910eb665" @@ -433,6 +447,14 @@ ], "version": "==0.6.1" }, + "mkdocs": { + "hashes": [ + "sha256:17d34329aad75d5de604b9ed4e31df3a4d235afefdc46ce7b1964fddb2e1e939", + "sha256:8cc8b38325456b9e942c981a209eaeb1e9f3f77b493ad755bfef889b9c8d356a" + ], + "index": "pypi", + "version": "==1.0.4" + }, "more-itertools": { "hashes": [ "sha256:c187a73da93e7a8acc0001572aebc7e3c69daf7bf6881a2cea10650bd4420092", @@ -494,8 +516,24 @@ "sha256:78f3f434bcc5d6ee09020f92ba487f95ba50f1e3ef83ae96b9d5ffa1bab25c5d", "sha256:dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc" ], + "index": "pypi", "version": "==2.2.0" }, + "pygments-github-lexers": { + "hashes": [ + "sha256:aaca57e77cd6fcfce8d6ee97a998962eebf7fbb810519a8ebde427c62823e133" + ], + "index": "pypi", + "version": "==0.0.5" + }, + "pymdown-extensions": { + "hashes": [ + "sha256:25b0a7967fa697b5035e23340a48594e3e93acb10b06d74574218ace3347d1df", + "sha256:6cf0cf36b5a03b291ace22dc2f320f4789ce56fbdb6635a3be5fadbf5d7694dd" + ], + "index": "pypi", + "version": "==6.0" + }, "pyparsing": { "hashes": [ "sha256:bc6c7146b91af3f567cf6daeaec360bc07d45ffec4cf5353f4d7a208ce7ca30a", @@ -518,6 +556,16 @@ ], "version": "==2018.5" }, + "pyyaml": { + "hashes": [ + "sha256:254bf6fda2b7c651837acb2c718e213df29d531eebf00edb54743d10bcb694eb", + "sha256:3108529b78577327d15eec243f0ff348a0640b0c3478d67ad7f5648f93bac3e2", + "sha256:3c17fb92c8ba2f525e4b5f7941d850e7a48c3a59b32d331e2502a3cdc6648e76", + "sha256:8d6d96001aa7f0a6a4a95e8143225b5d06e41b1131044913fecb8f85a125714b", + "sha256:c8a88edd93ee29ede719080b2be6cb2333dfee1dccba213b422a9c8e97f2967b" + ], + "version": "==4.2b4" + }, "readme-renderer": { "hashes": [ "sha256:237ca8705ffea849870de41101dba41543561da05c0ae45b2f1c547efa9843d2", @@ -575,6 +623,18 @@ ], "version": "==0.10.0" }, + "tornado": { + "hashes": [ + "sha256:0662d28b1ca9f67108c7e3b77afabfb9c7e87bde174fbda78186ecedc2499a9d", + "sha256:4e5158d97583502a7e2739951553cbd88a72076f152b4b11b64b9a10c4c49409", + "sha256:732e836008c708de2e89a31cb2fa6c0e5a70cb60492bee6f1ea1047500feaf7f", + "sha256:8154ec22c450df4e06b35f131adc4f2f3a12ec85981a203301d310abf580500f", + "sha256:8e9d728c4579682e837c92fdd98036bd5cdefa1da2aaf6acf26947e6dd0c01c5", + "sha256:d4b3e5329f572f055b587efc57d29bd051589fb5a43ec8898c77a47ec2fa2bbb", + "sha256:e5f2585afccbff22390cddac29849df463b252b711aa2ce7c5f3f342a5b3b444" + ], + "version": "==5.1.1" + }, "tqdm": { "hashes": [ "sha256:18f1818ce951aeb9ea162ae1098b43f583f7d057b34d706f66939353d1208889", diff --git a/docs/source/_static/custom.css b/docs/source/_static/custom.css new file mode 100644 index 0000000..8ada618 --- /dev/null +++ b/docs/source/_static/custom.css @@ -0,0 +1,7 @@ +/* Hide module name and default value for environment variable section */ +div[id$='environment-variables'] code.descclassname { + display: none; +} +div[id$='environment-variables'] em.property { + display: none; +} diff --git a/docs/source/_static/konami.js b/docs/source/_static/konami.js new file mode 100644 index 0000000..e002844 --- /dev/null +++ b/docs/source/_static/konami.js @@ -0,0 +1,151 @@ +/* + * Konami-JS ~ + * :: Now with support for touch events and multiple instances for + * :: those situations that call for multiple easter eggs! + * Code: https://github.com/snaptortoise/konami-js + * Copyright (c) 2009 George Mandis (georgemandis.com, snaptortoise.com) + * Version: 1.6.2 (7/17/2018) + * Licensed under the MIT License (http://opensource.org/licenses/MIT) + * Tested in: Safari 4+, Google Chrome 4+, Firefox 3+, IE7+, Mobile Safari 2.2.1+ and Android + */ + +var Konami = function (callback) { + var konami = { + addEvent: function (obj, type, fn, ref_obj) { + if (obj.addEventListener) + obj.addEventListener(type, fn, false); + else if (obj.attachEvent) { + // IE + obj["e" + type + fn] = fn; + obj[type + fn] = function () { + obj["e" + type + fn](window.event, ref_obj); + } + obj.attachEvent("on" + type, obj[type + fn]); + } + }, + removeEvent: function (obj, eventName, eventCallback) { + if (obj.removeEventListener) { + obj.removeEventListener(eventName, eventCallback); + } else if (obj.attachEvent) { + obj.detachEvent(eventName); + } + }, + input: "", + pattern: "38384040373937396665", + keydownHandler: function (e, ref_obj) { + if (ref_obj) { + konami = ref_obj; + } // IE + konami.input += e ? e.keyCode : event.keyCode; + if (konami.input.length > konami.pattern.length) { + konami.input = konami.input.substr((konami.input.length - konami.pattern.length)); + } + if (konami.input === konami.pattern) { + konami.code(konami._currentLink); + konami.input = ''; + e.preventDefault(); + return false; + } + }, + load: function (link) { + this._currentLink = link; + this.addEvent(document, "keydown", this.keydownHandler, this); + this.iphone.load(link); + }, + unload: function () { + this.removeEvent(document, 'keydown', this.keydownHandler); + this.iphone.unload(); + }, + code: function (link) { + window.location = link + }, + iphone: { + start_x: 0, + start_y: 0, + stop_x: 0, + stop_y: 0, + tap: false, + capture: false, + orig_keys: "", + keys: ["UP", "UP", "DOWN", "DOWN", "LEFT", "RIGHT", "LEFT", "RIGHT", "TAP", "TAP"], + input: [], + code: function (link) { + konami.code(link); + }, + touchmoveHandler: function (e) { + if (e.touches.length === 1 && konami.iphone.capture === true) { + var touch = e.touches[0]; + konami.iphone.stop_x = touch.pageX; + konami.iphone.stop_y = touch.pageY; + konami.iphone.tap = false; + konami.iphone.capture = false; + konami.iphone.check_direction(); + } + }, + touchendHandler: function () { + konami.iphone.input.push(konami.iphone.check_direction()); + + if (konami.iphone.input.length > konami.iphone.keys.length) konami.iphone.input.shift(); + + if (konami.iphone.input.length === konami.iphone.keys.length) { + var match = true; + for (var i = 0; i < konami.iphone.keys.length; i++) { + if (konami.iphone.input[i] !== konami.iphone.keys[i]) { + match = false; + } + } + if (match) { + konami.iphone.code(konami._currentLink); + } + } + }, + touchstartHandler: function (e) { + konami.iphone.start_x = e.changedTouches[0].pageX; + konami.iphone.start_y = e.changedTouches[0].pageY; + konami.iphone.tap = true; + konami.iphone.capture = true; + }, + load: function (link) { + this.orig_keys = this.keys; + konami.addEvent(document, "touchmove", this.touchmoveHandler); + konami.addEvent(document, "touchend", this.touchendHandler, false); + konami.addEvent(document, "touchstart", this.touchstartHandler); + }, + unload: function () { + konami.removeEvent(document, 'touchmove', this.touchmoveHandler); + konami.removeEvent(document, 'touchend', this.touchendHandler); + konami.removeEvent(document, 'touchstart', this.touchstartHandler); + }, + check_direction: function () { + x_magnitude = Math.abs(this.start_x - this.stop_x); + y_magnitude = Math.abs(this.start_y - this.stop_y); + x = ((this.start_x - this.stop_x) < 0) ? "RIGHT" : "LEFT"; + y = ((this.start_y - this.stop_y) < 0) ? "DOWN" : "UP"; + result = (x_magnitude > y_magnitude) ? x : y; + result = (this.tap === true) ? "TAP" : result; + return result; + } + } + } + + typeof callback === "string" && konami.load(callback); + if (typeof callback === "function") { + konami.code = callback; + konami.load(); + } + + return konami; +}; + + +if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { + module.exports = Konami; +} else { + if (typeof define === 'function' && define.amd) { + define([], function() { + return Konami; + }); + } else { + window.Konami = Konami; + } +} diff --git a/ext/Artboard 1@2x.png b/docs/source/_static/responder.png similarity index 100% rename from ext/Artboard 1@2x.png rename to docs/source/_static/responder.png diff --git a/docs/source/_templates/hacks.html b/docs/source/_templates/hacks.html new file mode 100644 index 0000000..3a91904 --- /dev/null +++ b/docs/source/_templates/hacks.html @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/source/_templates/sidebarintro.html b/docs/source/_templates/sidebarintro.html new file mode 100644 index 0000000..d55b6ad --- /dev/null +++ b/docs/source/_templates/sidebarintro.html @@ -0,0 +1,34 @@ + + +

+ +

+ +

+ Responder is web service framework, written for human beings. +

+ +

Stay Informed

+

Receive updates on new releases and upcoming projects.

+ +

+ +

+ +

+ + +

Useful Links

+ diff --git a/docs/source/_templates/sidebarlogo.html b/docs/source/_templates/sidebarlogo.html new file mode 100644 index 0000000..d55b6ad --- /dev/null +++ b/docs/source/_templates/sidebarlogo.html @@ -0,0 +1,34 @@ + + +

+ +

+ +

+ Responder is web service framework, written for human beings. +

+ +

Stay Informed

+

Receive updates on new releases and upcoming projects.

+ +

+ +

+ +

+ + +

Useful Links

+ diff --git a/docs/source/conf.py b/docs/source/conf.py index 966ca32..1b755d7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -19,14 +19,23 @@ # -- Project information ----------------------------------------------------- -project = 'responder' -copyright = '2018, Kenneth Reitz' -author = 'Kenneth Reitz' +project = "responder" +copyright = "2018, A Kenneth Reitz project." +author = "Kenneth Reitz" # The short X.Y version -version = '' +import os + +# Path hackery to get current version number. +here = os.path.abspath(os.path.dirname(__file__)) + +about = {} +with open(os.path.join(here, "..", "..", "responder", "__version__.py")) as f: + exec(f.read(), about) + +version = about["__version__"] # The full version, including alpha/beta/rc tags -release = '0.0.1' +release = about["__version__"] # -- General configuration --------------------------------------------------- @@ -39,28 +48,28 @@ release = '0.0.1' # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.mathjax', - 'sphinx.ext.ifconfig', - 'sphinx.ext.viewcode', - 'sphinx.ext.githubpages', + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.intersphinx", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.mathjax", + "sphinx.ext.ifconfig", + "sphinx.ext.viewcode", + "sphinx.ext.githubpages", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -83,18 +92,37 @@ pygments_style = None # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = "alabaster" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # -# html_theme_options = {} +html_theme_options = { + "show_powered_by": False, + "github_user": "kennethreitz", + "github_repo": "responder", + "github_banner": False, + "show_related": False, +} + + +html_sidebars = { + "index": ["sidebarintro.html", "sourcelink.html", "searchbox.html", "hacks.html"], + "**": [ + "sidebarlogo.html", + "localtoc.html", + "relations.html", + "sourcelink.html", + "searchbox.html", + "hacks.html", + ], +} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # Custom sidebar templates, must be a dictionary that maps document names # to template names. @@ -110,7 +138,7 @@ html_static_path = ['_static'] # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. -htmlhelp_basename = 'responderdoc' +htmlhelp_basename = "responderdoc" # -- Options for LaTeX output ------------------------------------------------ @@ -119,15 +147,12 @@ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. # # 'preamble': '', - # Latex figure (float) alignment # # 'figure_align': 'htbp', @@ -137,8 +162,7 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'responder.tex', 'responder Documentation', - 'Kenneth Reitz', 'manual'), + (master_doc, "responder.tex", "responder Documentation", "Kenneth Reitz", "manual") ] @@ -146,10 +170,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'responder', 'responder Documentation', - [author], 1) -] +man_pages = [(master_doc, "responder", "responder Documentation", [author], 1)] # -- Options for Texinfo output ---------------------------------------------- @@ -158,9 +179,15 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'responder', 'responder Documentation', - author, 'responder', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "responder", + "responder Documentation", + author, + "responder", + "One line description of project.", + "Miscellaneous", + ) ] @@ -179,7 +206,7 @@ epub_title = project # epub_uid = '' # A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] +epub_exclude_files = ["search.html"] # -- Extension configuration ------------------------------------------------- @@ -187,9 +214,9 @@ epub_exclude_files = ['search.html'] # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} +intersphinx_mapping = {"https://docs.python.org/": None} # -- Options for todo extension ---------------------------------------------- # If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True \ No newline at end of file +todo_include_todos = True diff --git a/responder/api.py b/responder/api.py index 06f514e..76942dd 100644 --- a/responder/api.py +++ b/responder/api.py @@ -216,10 +216,6 @@ class API: return route_object.url(**params) raise ValueError - def url(self): - # TODO: Current URL, somehow. - pass - def template(self, name, auto_escape=True, **values): # Give reference to self. values.update(api=self)