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 7 4.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 21 11.1 Arquivo models do modulo core..................................... 21 11.2 Arquivo views do modulo core...................................... 25 11.3 Licença.................................................. 25 12 Indices and tables 27 Python Module Index 29 i
ii
CHAPTER 1 Negrito e italico Código usado **negrito** ou *italico* Texto em negrito e em italico 1
Learn Sphinx Documentation Documentation, Release 0.0.1 2 Chapter 1. Negrito e italico
CHAPTER 2 Listas Código usado * Item 1 * Item 2 ou 1. Item 1 2. Item 2 3. Item 3 ou - Item 1 - Item 2 - Item 3 Saída: ou ou Item 1 Item 2 1. Item 1 2. Item 2 3. Item 3 Item 1 Item 2 Item 3 3
Learn Sphinx Documentation Documentation, Release 0.0.1 4 Chapter 2. Listas
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
Learn Sphinx Documentation Documentation, Release 0.0.1 6 Chapter 3. Titulos
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
Learn Sphinx Documentation Documentation, Release 0.0.1 8 Chapter 4. H1 Titulo
CHAPTER 5 Tabelas Código usado Tabela Simples: ===== ===== ====== Entrada Saida ------------ ------ A B A or B ===== ===== ====== False False False True False True False True True True True True ===== ===== ====== Saída: Tabela Simples: Entrada Saida A B A or B False False False True False True False True True True True True 9
Learn Sphinx Documentation Documentation, Release 0.0.1 10 Chapter 5. Tabelas
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
Learn Sphinx Documentation Documentation, Release 0.0.1 12 Chapter 6. Links
CHAPTER 7 Imagens Código usado.. figure::../images/cleo-pires-troll-face.jpg :width: 900px :align: center :alt: Troll Saída: Trollagem gratuita 13
Learn Sphinx Documentation Documentation, Release 0.0.1 Figure 7.1: Trollagem gratuita 14 Chapter 7. Imagens
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
Learn Sphinx Documentation Documentation, Release 0.0.1 16 Chapter 8. Substituições
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
Learn Sphinx Documentation Documentation, Release 0.0.1 18 Chapter 9. Includes
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
Learn Sphinx Documentation Documentation, Release 0.0.1 20 Chapter 10. Outros markups
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 by self.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
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 any errors 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 SQL insert 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, using=none) Does the heavy-lifting involved in saving. Subclasses shouldn t need to override this method. It s separate from 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 is returned directly. Used to serialize a field s value (in the serializer, or form output, for example). Normally, you would just access 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, tutoriais/artigos, class Meta abstract = False StandardItemStuffModel.clean() Hook for doing any extra model-wide validation after clean() has been called on every field by self.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
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 any errors 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 SQL insert 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 separate from 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 is returned directly. Used to serialize a field s value (in the serializer, or form output, for example). Normally, you would just access 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 Meta Definicoes da classe abstract = False Define a class como abstrata TimeStampedModel.clean() Hook for doing any extra model-wide validation after clean() has been called on every field by self.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 = None Variavel 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
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 any errors 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 = None Variavel para setar um campo no banco de dados do tipo DateTimeField. O valor é alterado toda vez que se 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 SQL insert 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 separate from 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 is returned directly. Used to serialize a field s value (in the serializer, or form output, for example). Normally, you would just access 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 seu model. Veja os detalhes logo abaixo: Created TimeStampedModel.created = None Variavel para setar um campo no banco de dados do tipo DateTimeField quando o registro for criado 24 Chapter 11. Códigos
Learn Sphinx Documentation Documentation, Release 0.0.1 Parameters auto_now_add (Boolean) Seta o valor True ou False Modified TimeStampedModel.modified = None Variavel para setar um campo no banco de dados do tipo DateTimeField. O valor é alterado toda vez que se faz update 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
Learn Sphinx Documentation Documentation, Release 0.0.1 26 Chapter 11. Códigos
CHAPTER 12 Indices and tables genindex modindex search 27
Learn Sphinx Documentation Documentation, Release 0.0.1 28 Chapter 12. Indices and tables
Python Module Index c core.models, 21 core.views, 25 29