diff --git a/_images/sphinx.png b/_images/sphinx.png new file mode 100644 index 0000000..63480af Binary files /dev/null and b/_images/sphinx.png differ diff --git a/python.html b/python.html index 75750ba..9bd065d 100644 --- a/python.html +++ b/python.html @@ -246,6 +246,11 @@ funcao(param = 1) + +
+

Um bloco sem nada dentro (por algum motivo), deve ser preenchido com, + pelo menos, pass.

+
@@ -1190,6 +1195,115 @@ Julio
+
+
+

Docstrings

+ +

Documentação de funções/classes é feita com uma string + logo abaixo da declaração da mesma.

+ +

+>>> def func(a):
+>>>     """Função mágica"""
+>>>     return a
+
+>>> print func.__doc__
+Função mágica
+
+>>> help(func)
+                        
+
+ +
+

Sphinx

+ +

Sphinx é o sistema de geração de documentação do Python.

+ + +
+ +
+

PEP 257

+ +

PEP 257 fala sobre formato de documentação de funções.

+
+ +
+
PEP 257
+ + + +

+class MyClass(object):
+
+    """This is my class. It is very long and I should break it
+    into several lines.
+    """
+
+    def __init__(self):
+        """Initialization."""
+        self.value = None
+                        
+
+ +
+

Sphinx Format

+ +

O Sphinx tem um formato específico para documentação.

+ + +
+ +
+

Sphinx Format (contd.)

+ +

+def send(sender, recipient, message_body, priority):
+   """Send a message to a recipient
+
+   :param str sender: The person sending the message
+   :param str recipient: The recipient of the message
+   :param str message_body: The body of the message
+   :param priority: The priority of the message, can be a number 1-5
+   :type priority: integer or None
+   :return: the message id
+   :rtype: int
+   :raises ValueError: if the message_body exceeds 160 characters
+   :raises TypeError: if the message_body is not a basestring
+   """
+   pass
+                        
+
+ +
+

(como gerar documentação Sphinx não será apresentado por + questões de espaço.)

+ +

(mas é simples: um arquivo conf com os + diretórios a serem pesquisados e um makefile com a opção + html para geração de arquivos HTML.)

+
+
+ +
+
+

VirtualEnv

+
+
+