{ "metadata": { "name": "Capitulo7_Documentacao" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[Python para Desenvolvedores](http://ricardoduarte.github.io/python-para-desenvolvedores/#conteudo)\n", "===================================\n", "2ª edi\u00e7\u00e3o, revisada e ampliada\n", "-----------------------------------\n", "\n", "Cap\u00edtulo 7: Documenta\u00e7\u00e3o\n", "=============================\n", "_____________________________\n", "PyDOC \u00e9 a ferramenta de documenta\u00e7\u00e3o do Python. Ela pode ser utilizada tanto para acessar a documenta\u00e7\u00e3o dos m\u00f3dulos que acompanham o Python, quanto a documenta\u00e7\u00e3o dos m\u00f3dulos de terceiros.\n", "\n", "No Windows, acesse o \u00edcone \u201cModule Docs\u201d para a documenta\u00e7\u00e3o da biblioteca padr\u00e3o e \u201cPython Manuals\u201d para consultar o tutorial, refer\u00eancias e outros documentos mais extensos.\n", "\n", "Para utilizar o PyDOC no Linux:\n", "\n", " pydoc ./modulo.py\n", "\n", "Para exibir a documenta\u00e7\u00e3o de `modulo.py` no diret\u00f3rio atual.\n", "\n", "No Linux, a documenta\u00e7\u00e3o das bibliotecas pode ser vista atrav\u00e9s do *browser* usando o comando:\n", "\n", " pydoc -p 8000\n", "\n", "No endere\u00e7o http://localhost:8000/.\n", "Para rodar a vers\u00e3o gr\u00e1fica do PyDOC execute:\n", "\n", " pydoc -g\n", "\n", "O PyDOC utiliza as *Doc Strings* dos m\u00f3dulos para gerar a documenta\u00e7\u00e3o.\n", "\n", "Al\u00e9m disso, \u00e9 poss\u00edvel ainda consultar a documenta\u00e7\u00e3o no pr\u00f3prio interpretador, atrav\u00e9s da fun\u00e7\u00e3o `help()`.\n", "\n", "Exemplo:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "help(list)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Help on class list in module __builtin__:\n", "\n", "class list(object)\n", " | list() -> new empty list\n", " | list(iterable) -> new list initialized from iterable's items\n", " | \n", " | Methods defined here:\n", " | \n", " | __add__(...)\n", " | x.__add__(y) <==> x+y\n", " | \n", " | __contains__(...)\n", " | x.__contains__(y) <==> y in x\n", " | \n", " | __delitem__(...)\n", " | x.__delitem__(y) <==> del x[y]\n", " | \n", " | __delslice__(...)\n", " | x.__delslice__(i, j) <==> del x[i:j]\n", " | \n", " | Use of negative indices is not supported.\n", " | \n", " | __eq__(...)\n", " | x.__eq__(y) <==> x==y\n", " | \n", " | __ge__(...)\n", " | x.__ge__(y) <==> x>=y\n", " | \n", " | __getattribute__(...)\n", " | x.__getattribute__('name') <==> x.name\n", " | \n", " | __getitem__(...)\n", " | x.__getitem__(y) <==> x[y]\n", " | \n", " | __getslice__(...)\n", " | x.__getslice__(i, j) <==> x[i:j]\n", " | \n", " | Use of negative indices is not supported.\n", " | \n", " | __gt__(...)\n", " | x.__gt__(y) <==> x>y\n", " | \n", " | __iadd__(...)\n", " | x.__iadd__(y) <==> x+=y\n", " | \n", " | __imul__(...)\n", " | x.__imul__(y) <==> x*=y\n", " | \n", " | __init__(...)\n", " | x.__init__(...) initializes x; see help(type(x)) for signature\n", " | \n", " | __iter__(...)\n", " | x.__iter__() <==> iter(x)\n", " | \n", " | __le__(...)\n", " | x.__le__(y) <==> x<=y\n", " | \n", " | __len__(...)\n", " | x.__len__() <==> len(x)\n", " | \n", " | __lt__(...)\n", " | x.__lt__(y) <==> x x*n\n", " | \n", " | __ne__(...)\n", " | x.__ne__(y) <==> x!=y\n", " | \n", " | __repr__(...)\n", " | x.__repr__() <==> repr(x)\n", " | \n", " | __reversed__(...)\n", " | L.__reversed__() -- return a reverse iterator over the list\n", " | \n", " | __rmul__(...)\n", " | x.__rmul__(n) <==> n*x\n", " | \n", " | __setitem__(...)\n", " | x.__setitem__(i, y) <==> x[i]=y\n", " | \n", " | __setslice__(...)\n", " | x.__setslice__(i, j, y) <==> x[i:j]=y\n", " | \n", " | Use of negative indices is not supported.\n", " | \n", " | __sizeof__(...)\n", " | L.__sizeof__() -- size of L in memory, in bytes\n", " | \n", " | append(...)\n", " | L.append(object) -- append object to end\n", " | \n", " | count(...)\n", " | L.count(value) -> integer -- return number of occurrences of value\n", " | \n", " | extend(...)\n", " | L.extend(iterable) -- extend list by appending elements from the iterable\n", " | \n", " | index(...)\n", " | L.index(value, [start, [stop]]) -> integer -- return first index of value.\n", " | Raises ValueError if the value is not present.\n", " | \n", " | insert(...)\n", " | L.insert(index, object) -- insert object before index\n", " | \n", " | pop(...)\n", " | L.pop([index]) -> item -- remove and return item at index (default last).\n", " | Raises IndexError if list is empty or index is out of range.\n", " | \n", " | remove(...)\n", " | L.remove(value) -- remove first occurrence of value.\n", " | Raises ValueError if the value is not present.\n", " | \n", " | reverse(...)\n", " | L.reverse() -- reverse *IN PLACE*\n", " | \n", " | sort(...)\n", " | L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;\n", " | cmp(x, y) -> -1, 0, 1\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data and other attributes defined here:\n", " | \n", " | __hash__ = None\n", " | \n", " | __new__ = \n", " | T.__new__(S, ...) -> a new object with type S, a subtype of T\n", "\n" ] } ], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Mostra a documenta\u00e7\u00e3o para a lista do Python." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "" ], "output_type": "pyout", "prompt_number": 1, "text": [ "" ] } ], "prompt_number": 1 } ], "metadata": {} } ] }