learn sphinx documentation documentation · learn sphinx documentation documentation release 0.0.1...

33
Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Upload: others

Post on 24-Jul-2020

154 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx DocumentationDocumentation

Release 0.0.1

Lucas Simon Rodrigues Magalhaes

January 31, 2014

Page 2: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014
Page 3: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Contents

1 Negrito e italico 1

2 Listas 3

3 Titulos 5

4 H1 – Titulo 74.1 H2 – Sub-Titulo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

5 Tabelas 9

6 Links 11

7 Imagens 13

8 Substituições 15

9 Includes 17

10 Outros markups 19

11 Códigos 2111.1 Arquivo models do modulo core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2111.2 Arquivo views do modulo core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2511.3 Licença . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

12 Indices and tables 27

Python Module Index 29

i

Page 4: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

ii

Page 5: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 1

Negrito e italico

Código usado

**negrito** ou *italico*

Texto em negrito e em italico

1

Page 6: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

2 Chapter 1. Negrito e italico

Page 7: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 2

Listas

Código usado

* Item 1

* Item 2

ou

1. Item 12. Item 23. Item 3

ou

- Item 1- Item 2- Item 3

Saída:

• Item 1

• Item 2

ou

1. Item 1

2. Item 2

3. Item 3

ou

• Item 1

• Item 2

• Item 3

3

Page 8: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

4 Chapter 2. Listas

Page 9: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 3

Titulos

Código usado

H1 -- Titulo============

Paragrafo qualquer

H2 -- Sub-Titulo

****************

Paragrafo do subtitulo

H3 -- Sub-seção---------------

Paragrafo da subseção

H4 -- 4 nível da subseção+++++++++++++++++++++++++

Nivel 4

Saída:

5

Page 10: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

6 Chapter 3. Titulos

Page 11: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 4

H1 – Titulo

Paragrafo qualquer

4.1 H2 – Sub-Titulo

Paragrafo do subtitulo

4.1.1 H3 – Sub-seção

Paragrafo da subseção

H4 – 4 nível da subseção

Nivel 4

7

Page 12: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

8 Chapter 4. H1 – Titulo

Page 13: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 5

Tabelas

Código usado

Tabela Simples:

===== ===== ======Entrada Saida

------------ ------A B A or B

===== ===== ======False False FalseTrue False TrueFalse True TrueTrue True True===== ===== ======

Saída:

Tabela Simples:

Entrada SaidaA B A or BFalse False FalseTrue False TrueFalse True TrueTrue True True

9

Page 14: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

10 Chapter 5. Tabelas

Page 15: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 6

Links

Urls são automaticamente linkadas http://packages.python.org/an_example_pypi_project/

Para outros links, usa-se o operador _

‘Django <https://docs.djangoproject.com/en/1.6/>‘_

Para adicionar um texto com um link, use esse formato:

Clique no link para acessar a documentação do Django

11

Page 16: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

12 Chapter 6. Links

Page 17: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 7

Imagens

Código usado

.. figure:: ../images/Cleo-Pires-Troll-Face.jpg:width: 900px:align: center:alt: Troll

Trollagem gratuita

Saída:

13

Page 18: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

Figure 7.1: Trollagem gratuita

14 Chapter 7. Imagens

Page 19: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 8

Substituições

Código usado

.. |django| image:: ../images/django-icon-256.png

O icone do |django| esta muitooooooo grande

O icone do esta muitooooooo grande

15

Page 20: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

16 Chapter 8. Substituições

Page 21: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 9

Includes

Código usado

.. include myfile.rst

O arquivo será incluido a partir desse momento.

Util para separar arquivos de changelog.md ou contribuitors.md. E depois somente inclui-los ao texto principal

17

Page 22: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

18 Chapter 9. Includes

Page 23: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 10

Outros markups

Código usado

.. note::Verique se os parametros passados estão corretos!

.. warning::Nunca use esse código!

.. versionadded:: 0.0.1

.. versionchanged:: 0.0.2

.. seealso::Algum outro módulo

Saída:

Note: Verique se os parametros passados estão corretos!

Warning: Nunca use esse código!

New in version 0.0.1.

Changed in version 0.0.2.

See also:

Algum outro módulo

19

Page 24: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

20 Chapter 10. Outros markups

Page 25: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 11

Códigos

Para blocos de códigos utilize ::

Código usado

def my_fn(foo, bar=True):"""A really useful function.

Returns None"""Code

Para códigos simples utilize apenas ‘‘ ‘‘‘

‘‘if __name__ == ’__main__’:‘‘

Arquivo qualquer *.py pode conter if __name__ == ’__main__’:

Contents:

11.1 Arquivo models do modulo core

class core.models.Media(*args, **kwargs)Bases: core.models.TimeStampedModel

Classe model para cadastrar as medias com os as apps de palestras/talks, screencasts, tutoriais/artigos,

class Meta

abstract = False

Media.clean()Hook for doing any extra model-wide validation after clean() has been called on every field byself.clean_fields. Any ValidationError raised by this method will not be associated with a particular field;it will have a special-case association with the field defined by NON_FIELD_ERRORS.

Media.clean_fields(exclude=None)Cleans all fields and raises a ValidationError containing message_dict of all validation errors if any occur.

Media.date_error_message(lookup_type, field, unique_for)

Media.delete(using=None)

21

Page 26: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

Media.full_clean(exclude=None)Calls clean_fields, clean, and validate_unique, on the model, and raises a ValidationError for anyerrors that occured.

Media.get_next_by_created(*moreargs, **morekwargs)

Media.get_next_by_modified(*moreargs, **morekwargs)

Media.get_previous_by_created(*moreargs, **morekwargs)

Media.get_previous_by_modified(*moreargs, **morekwargs)

Media.get_type_display(*moreargs, **morekwargs)

Media.pk

Media.prepare_database_save(unused)

Media.save(force_insert=False, force_update=False, using=None)Saves the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQLinsert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

Media.save_base(raw=False, cls=None, origin=None, force_insert=False, force_update=False, us-ing=None)

Does the heavy-lifting involved in saving. Subclasses shouldn’t need to override this method. It’s separatefrom save() in order to hide the need for overrides of save() to pass around internal-only parameters (‘raw’,‘cls’, and ‘origin’).

Media.serializable_value(field_name)Returns the value of the field name for this instance. If the field is a foreign key, returns the id value,instead of the object. If there’s no Field object with this name on the model, the model attribute’s value isreturned directly.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would justaccess the attribute directly and not use this method.

Media.unique_error_message(model_class, unique_check)

Media.validate_unique(exclude=None)Checks unique constraints on the model and raises ValidationError if any failed.

class core.models.StandardItemStuffModel(*args, **kwargs)Bases: django.db.models.base.Model

Classe abstrata para comportar campos em comum com os as apps de palestras/talks, screencasts, tutori-ais/artigos,

class Meta

abstract = False

StandardItemStuffModel.clean()Hook for doing any extra model-wide validation after clean() has been called on every field byself.clean_fields. Any ValidationError raised by this method will not be associated with a particular field;it will have a special-case association with the field defined by NON_FIELD_ERRORS.

StandardItemStuffModel.clean_fields(exclude=None)Cleans all fields and raises a ValidationError containing message_dict of all validation errors if any occur.

StandardItemStuffModel.date_error_message(lookup_type, field, unique_for)

StandardItemStuffModel.delete(using=None)

22 Chapter 11. Códigos

Page 27: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

StandardItemStuffModel.full_clean(exclude=None)Calls clean_fields, clean, and validate_unique, on the model, and raises a ValidationError for anyerrors that occured.

StandardItemStuffModel.pk

StandardItemStuffModel.prepare_database_save(unused)

StandardItemStuffModel.save(force_insert=False, force_update=False, using=None)Saves the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQLinsert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

StandardItemStuffModel.save_base(raw=False, cls=None, origin=None,force_insert=False, force_update=False, using=None)

Does the heavy-lifting involved in saving. Subclasses shouldn’t need to override this method. It’s separatefrom save() in order to hide the need for overrides of save() to pass around internal-only parameters (‘raw’,‘cls’, and ‘origin’).

StandardItemStuffModel.serializable_value(field_name)Returns the value of the field name for this instance. If the field is a foreign key, returns the id value,instead of the object. If there’s no Field object with this name on the model, the model attribute’s value isreturned directly.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would justaccess the attribute directly and not use this method.

StandardItemStuffModel.speaker

StandardItemStuffModel.unique_error_message(model_class, unique_check)

StandardItemStuffModel.validate_unique(exclude=None)Checks unique constraints on the model and raises ValidationError if any failed.

class core.models.TimeStampedModel(*args, **kwargs)Bases: django.db.models.base.Model

An abstract base class model that provides self-updating created and modified fields.

Note: An example of intersphinx is this: you cannot use pickle on this class.

class MetaDefinicoes da classe

abstract = FalseDefine a class como abstrata

TimeStampedModel.clean()Hook for doing any extra model-wide validation after clean() has been called on every field byself.clean_fields. Any ValidationError raised by this method will not be associated with a particular field;it will have a special-case association with the field defined by NON_FIELD_ERRORS.

TimeStampedModel.clean_fields(exclude=None)Cleans all fields and raises a ValidationError containing message_dict of all validation errors if any occur.

TimeStampedModel.created = NoneVariavel para setar um campo no banco de dados do tipo DateTimeField quando o registro for criado

Parameters auto_now_add (Boolean) – Seta o valor True ou False

TimeStampedModel.date_error_message(lookup_type, field, unique_for)

11.1. Arquivo models do modulo core 23

Page 28: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

TimeStampedModel.delete(using=None)

TimeStampedModel.full_clean(exclude=None)Calls clean_fields, clean, and validate_unique, on the model, and raises a ValidationError for anyerrors that occured.

TimeStampedModel.get_next_by_created(*moreargs, **morekwargs)

TimeStampedModel.get_next_by_modified(*moreargs, **morekwargs)

TimeStampedModel.get_previous_by_created(*moreargs, **morekwargs)

TimeStampedModel.get_previous_by_modified(*moreargs, **morekwargs)

TimeStampedModel.modified = NoneVariavel para setar um campo no banco de dados do tipo DateTimeField. O valor é alterado toda vez quese faz update no registro da tabela

Parameters auto_now (Boolean) – Seta o valor True ou False

TimeStampedModel.pk

TimeStampedModel.prepare_database_save(unused)

TimeStampedModel.save(force_insert=False, force_update=False, using=None)Saves the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQLinsert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

TimeStampedModel.save_base(raw=False, cls=None, origin=None, force_insert=False,force_update=False, using=None)

Does the heavy-lifting involved in saving. Subclasses shouldn’t need to override this method. It’s separatefrom save() in order to hide the need for overrides of save() to pass around internal-only parameters (‘raw’,‘cls’, and ‘origin’).

TimeStampedModel.serializable_value(field_name)Returns the value of the field name for this instance. If the field is a foreign key, returns the id value,instead of the object. If there’s no Field object with this name on the model, the model attribute’s value isreturned directly.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would justaccess the attribute directly and not use this method.

TimeStampedModel.unique_error_message(model_class, unique_check)

TimeStampedModel.validate_unique(exclude=None)Checks unique constraints on the model and raises ValidationError if any failed.

11.1.1 Classe model TimeStampedModel

Classe model do tipo abstrata.

Seu objetivo é que ela possa ser herdada por outras classes models incluindo os campos created e modified ao seumodel.

Veja os detalhes logo abaixo:

Created

TimeStampedModel.created = NoneVariavel para setar um campo no banco de dados do tipo DateTimeField quando o registro for criado

24 Chapter 11. Códigos

Page 29: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

Parameters auto_now_add (Boolean) – Seta o valor True ou False

Modified

TimeStampedModel.modified = NoneVariavel para setar um campo no banco de dados do tipo DateTimeField. O valor é alterado toda vez que se fazupdate no registro da tabela

Parameters auto_now (Boolean) – Seta o valor True ou False

11.2 Arquivo views do modulo core

core.views.foo(bar=None)Metodo para exemplificar como o sphinx renderiza as docstring.

Parameters bar (Integer or None) – Recebe um valor inteiro

Returns list or strings – Retona uma lista vazia ou uma string

Return type list of strings – asdsadsad

Raises AttributeError, KeyError

>>> print foo()[]>>> print foo(’texto’)texto

11.3 Licença

Distribuido sobre a licença BSD.

11.2. Arquivo views do modulo core 25

Page 30: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

26 Chapter 11. Códigos

Page 31: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

CHAPTER 12

Indices and tables

• genindex

• modindex

• search

27

Page 32: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Learn Sphinx Documentation Documentation, Release 0.0.1

28 Chapter 12. Indices and tables

Page 33: Learn Sphinx Documentation Documentation · Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014

Python Module Index

ccore.models, 21core.views, 25

29