From d3947a6dc7b280e68fd3979b9e767f9cdc69645a Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Sat, 16 Feb 2013 14:03:49 +0100 Subject: [PATCH] Added a type hinting recipe to docs (refs #133) --- docs/docs/features.rst | 3 ++- docs/docs/recipes.rst | 44 ++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 docs/docs/recipes.rst diff --git a/docs/docs/features.rst b/docs/docs/features.rst index 21c34b65..6038e37e 100644 --- a/docs/docs/features.rst +++ b/docs/docs/features.rst @@ -13,7 +13,8 @@ General Features - ignores syntax errors and wrong indentation - can deal with complex module / function / class structures - virtualenv support -- can infer function arguments from sphinx and epydoc docstrings +- can infer function arguments from sphinx and epydoc docstrings (:ref:`type + hinting `) Supported Python Features diff --git a/docs/docs/recipes.rst b/docs/docs/recipes.rst new file mode 100644 index 00000000..63ff1d0a --- /dev/null +++ b/docs/docs/recipes.rst @@ -0,0 +1,44 @@ +.. include:: ../global.rst + +Recipes +======= + +Here are some tips on how to use |jedi| efficiently. + + +.. _type-hinting: + +Type Hinting +------------ + +If |jedi| cannot detect the type of a function argument correctly (due to the +dynamic nature of Python), you can help it by hinting the type using +Sphinx-style info field lists or Epydoc docstrings. + +**Sphinx style** + +http://sphinx-doc.org/domains.html#info-field-lists + +:: + + def myfunction(node): + """Do something with a ``node``. + + :type node: ProgramNode + + """ + node.| # complete here + +**Epydoc** + +http://epydoc.sourceforge.net/manual-fields.html + +:: + + def myfunction(node): + """Do something with a ``node``. + + @param node: ProgramNode + + """ + node.| # complete here diff --git a/docs/index.rst b/docs/index.rst index c91b720d..6f7c19fc 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -22,6 +22,7 @@ Docs docs/installation docs/features + docs/recipes docs/plugin-api docs/history docs/development