diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/Makefile | 2 | ||||
-rw-r--r-- | Doc/library/functions.rst | 26 | ||||
-rw-r--r-- | Doc/library/idle.rst | 49 | ||||
-rw-r--r-- | Doc/library/stdtypes.rst | 12 | ||||
-rw-r--r-- | Doc/library/unittest.rst | 7 | ||||
-rw-r--r-- | Doc/reference/compound_stmts.rst | 3 | ||||
-rw-r--r-- | Doc/tools/sphinxext/layout.html | 12 | ||||
-rw-r--r-- | Doc/tools/sphinxext/static/version_switch.js | 66 | ||||
-rw-r--r-- | Doc/tutorial/inputoutput.rst | 7 | ||||
-rw-r--r-- | Doc/tutorial/stdlib2.rst | 4 |
10 files changed, 144 insertions, 44 deletions
diff --git a/Doc/Makefile b/Doc/Makefile index cb56ea9..13411f2 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -185,7 +185,7 @@ serve: # for development releases: always build autobuild-dev: make update - make dist SPHINXOPTS='-A daily=1' + make dist SPHINXOPTS='-A daily=1 -A versionswitcher=1' # for stable releases: only build if not in pre-release stage (alpha, beta, rc) autobuild-stable: diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index b7d7e08..31d8cf1 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1353,29 +1353,25 @@ are always available. They are listed here in alphabetical order. .. function:: type(object) + type(name, bases, dict) .. index:: object: type - Return the type of an *object*. The return value is a type object and - generally the same object as returned by ``object.__class__``. + + With one argument, return the type of an *object*. The return value is a + type object and generally the same object as returned by ``object.__class__``. The :func:`isinstance` built-in function is recommended for testing the type of an object, because it takes subclasses into account. - With three arguments, :func:`type` functions as a constructor as detailed - below. - - -.. function:: type(name, bases, dict) - :noindex: - Return a new type object. This is essentially a dynamic form of the - :keyword:`class` statement. The *name* string is the class name and becomes the - :attr:`__name__` attribute; the *bases* tuple itemizes the base classes and - becomes the :attr:`__bases__` attribute; and the *dict* dictionary is the - namespace containing definitions for class body and becomes the :attr:`__dict__` - attribute. For example, the following two statements create identical - :class:`type` objects: + With three arguments, return a new type object. This is essentially a + dynamic form of the :keyword:`class` statement. The *name* string is the + class name and becomes the :attr:`__name__` attribute; the *bases* tuple + itemizes the base classes and becomes the :attr:`__bases__` attribute; + and the *dict* dictionary is the namespace containing definitions for class + body and becomes the :attr:`__dict__` attribute. For example, the + following two statements create identical :class:`type` objects: >>> class X: ... a = 1 diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index 6bd1898..5f28a99 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -154,27 +154,56 @@ The rest of this menu lists the names of all open windows; select one to bring it to the foreground (deiconifying it if necessary). -Debug menu (in the Python Shell window only) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Debug menu +^^^^^^^^^^ + +* in the Python Shell window only Go to file/line - look around the insert point for a filename and linenumber, open the file, and - show the line. + Look around the insert point for a filename and line number, open the file, + and show the line. Useful to view the source lines referenced in an + exception traceback. -Open stack viewer - show the stack traceback of the last exception +Debugger + Run commands in the shell under the debugger. -Debugger toggle - Run commands in the shell under the debugger +Stack viewer + Show the stack traceback of the last exception. -JIT Stack viewer toggle - Open stack viewer on traceback +Auto-open Stack Viewer + Open stack viewer on traceback. .. index:: single: stack viewer single: debugger +Edit context menu +^^^^^^^^^^^^^^^^^ + +* Right-click in Edit window (Control-click on OS X) + +Set Breakpoint + Sets a breakpoint. Breakpoints are only enabled when the debugger is open. + +Clear Breakpoint + Clears the breakpoint on that line. + +.. index:: + single: Set Breakpoint + single: Clear Breakpoint + single: breakpoints + + +Shell context menu +^^^^^^^^^^^^^^^^^^ + +* Right-click in Python Shell window (Control-click on OS X) + +Go to file/line + Same as in Debug menu. + + Basic editing and navigation ---------------------------- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 20174c5..78a2799 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2137,13 +2137,13 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: replaces the value from the positional argument. To illustrate, the following examples all return a dictionary equal to - ``{"one": 1, "two": 2}``:: + ``{"one": 1, "two": 2, "three": 3}``:: - >>> a = dict(one=1, two=2) - >>> b = dict({'one': 1, 'two': 2}) - >>> c = dict(zip(('one', 'two'), (1, 2))) - >>> d = dict([['two', 2], ['one', 1]]) - >>> e = {"one": 1, "two": 2} + >>> a = dict(one=1, two=2, three=3) + >>> b = {'one': 1, 'two': 2, 'three': 3} + >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3])) + >>> d = dict([('two', 2), ('one', 1), ('three', 3)]) + >>> e = dict({'three': 3, 'one': 1, 'two': 2}) >>> a == b == c == d == e True diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index 72a3a7b..4422533 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -99,9 +99,10 @@ need to derive from a specific class. The script :file:`Tools/unittestgui/unittestgui.py` in the Python source distribution is a GUI tool for test discovery and execution. This is intended largely for ease of use - for those new to unit testing. For production environments it is recommended that - tests be driven by a continuous integration system such as `Hudson <http://hudson-ci.org/>`_ - or `Buildbot <http://buildbot.net/trac>`_. + for those new to unit testing. For production environments it is + recommended that tests be driven by a continuous integration system such as + `Buildbot <http://buildbot.net/trac>`_, `Jenkins <http://jenkins-ci.org>`_ + or `Hudson <http://hudson-ci.org/>`_. .. _unittest-minimal-example: diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 003224b..6889176 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -442,8 +442,7 @@ A function definition defines a user-defined function object (see section decorator: "@" `dotted_name` ["(" [`parameter_list` [","]] ")"] NEWLINE dotted_name: `identifier` ("." `identifier`)* parameter_list: (`defparameter` ",")* - : ( "*" [`parameter`] ("," `defparameter`)* - : [, "**" `parameter`] + : ( "*" [`parameter`] ("," `defparameter`)* ["," "**" `parameter`] : | "**" `parameter` : | `defparameter` [","] ) parameter: `identifier` [":" `expression`] diff --git a/Doc/tools/sphinxext/layout.html b/Doc/tools/sphinxext/layout.html index db4a386..4b16b3f 100644 --- a/Doc/tools/sphinxext/layout.html +++ b/Doc/tools/sphinxext/layout.html @@ -3,18 +3,26 @@ <li><img src="{{ pathto('_static/py.png', 1) }}" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a>{{ reldelim1 }}</li> - <li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li> + <li> + {%- if versionswitcher is defined %} + <span class="version_switcher_placeholder">{{ release }}</span> + <a href="{{ pathto('index') }}">Documentation</a>{{ reldelim1 }} + {%- else %} + <a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }} + {%- endif %} + </li> {% endblock %} {% block extrahead %} <link rel="shortcut icon" type="image/png" href="{{ pathto('_static/py.png', 1) }}" /> {% if not embedded %}<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>{% endif %} + {% if versionswitcher is defined and not embedded %}<script type="text/javascript" src="{{ pathto('_static/version_switch.js', 1) }}"></script>{% endif %} {{ super() }} {% endblock %} {% block footer %} <div class="footer"> © <a href="{{ pathto('copyright') }}">Copyright</a> {{ copyright|e }}. <br /> - The Python Software Foundation is a non-profit corporation. + The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on {{ last_updated|e }}. diff --git a/Doc/tools/sphinxext/static/version_switch.js b/Doc/tools/sphinxext/static/version_switch.js new file mode 100644 index 0000000..cc7be1c --- /dev/null +++ b/Doc/tools/sphinxext/static/version_switch.js @@ -0,0 +1,66 @@ +(function() { + 'use strict'; + + var all_versions = { + '3.4': 'dev (3.4)', + '3.3': '3.3', + '3.2': '3.2', + '2.7': '2.7', + '2.6': '2.6' + }; + + function build_select(current_version, current_release) { + var buf = ['<select>']; + + $.each(all_versions, function(version, title) { + buf.push('<option value="' + version + '"'); + if (version == current_version) + buf.push(' selected="selected">' + current_release + '</option>'); + else + buf.push('>' + title + '</option>'); + }); + + buf.push('</select>'); + return buf.join(''); + } + + function patch_url(url, new_version) { + var url_re = /\.org\/(\d|py3k|dev|((release\/)?\d\.\d[\w\d\.]*))\//, + new_url = url.replace(url_re, '.org/' + new_version + '/'); + + if (new_url == url && !new_url.match(url_re)) { + // python 2 url without version? + new_url = url.replace(/\.org\//, '.org/' + new_version + '/'); + } + return new_url; + } + + function on_switch() { + var selected = $(this).children('option:selected').attr('value'); + + var url = window.location.href, + new_url = patch_url(url, selected); + + if (new_url != url) { + // check beforehand if url exists, else redirect to version's start page + $.ajax({ + url: new_url, + success: function() { + window.location.href = new_url; + }, + error: function() { + window.location.href = 'http://docs.python.org/' + selected; + } + }); + } + } + + $(document).ready(function() { + var release = DOCUMENTATION_OPTIONS.VERSION; + var version = release.substr(0, 3); + var select = build_select(version, release); + + $('.version_switcher_placeholder').html(select); + $('.version_switcher_placeholder select').bind('change', on_switch); + }); +})(); diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index 73143be..1324359 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -256,9 +256,10 @@ default being UTF-8). ``'b'`` appended to the mode opens the file in :dfn:`binary mode`: now the data is read and written in the form of bytes objects. This mode should be used for all files that don't contain text. -In text mode, the default is to convert platform-specific line endings (``\n`` -on Unix, ``\r\n`` on Windows) to just ``\n`` on reading and ``\n`` back to -platform-specific line endings on writing. This behind-the-scenes modification +In text mode, the default when reading is to convert platform-specific line +endings (``\n`` on Unix, ``\r\n`` on Windows) to just ``\n``. When writing in +text mode, the default is to convert occurrences of ``\n`` back to +platform-specific line endings. This behind-the-scenes modification to file data is fine for text files, but will corrupt binary data like that in :file:`JPEG` or :file:`EXE` files. Be very careful to use binary mode when reading and writing such files. diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst index a9ae871..2265cd0 100644 --- a/Doc/tutorial/stdlib2.rst +++ b/Doc/tutorial/stdlib2.rst @@ -257,9 +257,9 @@ applications include caching objects that are expensive to create:: >>> import weakref, gc >>> class A: ... def __init__(self, value): - ... self.value = value + ... self.value = value ... def __repr__(self): - ... return str(self.value) + ... return str(self.value) ... >>> a = A(10) # create a reference >>> d = weakref.WeakValueDictionary() |