development.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. .. _development:
  2. Development
  3. ===========
  4. Tablib is under active development, and contributors are welcome.
  5. If you have a feature request, suggestion, or bug report, please open a new
  6. issue on GitHub_. To submit patches, please send a pull request on GitHub_.
  7. .. _GitHub: https://github.com/jazzband/tablib/
  8. .. _design:
  9. ---------------------
  10. Design Considerations
  11. ---------------------
  12. Tablib was developed with a few :pep:`20` idioms in mind.
  13. #. Beautiful is better than ugly.
  14. #. Explicit is better than implicit.
  15. #. Simple is better than complex.
  16. #. Complex is better than complicated.
  17. #. Readability counts.
  18. A few other things to keep in mind:
  19. #. Keep your code DRY.
  20. #. Strive to be as simple (to use) as possible.
  21. .. _scm:
  22. --------------
  23. Source Control
  24. --------------
  25. Tablib source is controlled with Git_, the lean, mean, distributed source
  26. control machine.
  27. The repository is publicly accessible.
  28. .. code-block:: console
  29. git clone git://github.com/jazzband/tablib.git
  30. The project is hosted on **GitHub**.
  31. GitHub:
  32. https://github.com/jazzband/tablib
  33. Git Branch Structure
  34. ++++++++++++++++++++
  35. Feature / Hotfix / Release branches follow a `Successful Git Branching Model`_ .
  36. Git-flow_ is a great tool for managing the repository. I highly recommend it.
  37. ``master``
  38. Current production release (|version|) on PyPi.
  39. Each release is tagged.
  40. When submitting patches, please place your feature/change in its own branch prior to opening a pull request on GitHub_.
  41. .. _Git: https://git-scm.org
  42. .. _`Successful Git Branching Model`: https://nvie.com/posts/a-successful-git-branching-model/
  43. .. _git-flow: https://github.com/nvie/gitflow
  44. .. _newformats:
  45. ------------------
  46. Adding New Formats
  47. ------------------
  48. Tablib welcomes new format additions! Format suggestions include:
  49. * MySQL Dump
  50. Coding by Convention
  51. ++++++++++++++++++++
  52. Tablib features a micro-framework for adding format support.
  53. The easiest way to understand it is to use it.
  54. So, let's define our own format, named *xxx*.
  55. 1. Write a new format interface.
  56. :class:`tablib.core` follows a simple pattern for automatically utilizing your format throughout Tablib.
  57. Function names are crucial.
  58. Example **tablib/formats/_xxx.py**: ::
  59. title = 'xxx'
  60. def export_set(dset):
  61. ....
  62. # returns string representation of given dataset
  63. def export_book(dbook):
  64. ....
  65. # returns string representation of given databook
  66. def import_set(dset, in_stream):
  67. ...
  68. # populates given Dataset with given datastream
  69. def import_book(dbook, in_stream):
  70. ...
  71. # returns Databook instance
  72. def detect(stream):
  73. ...
  74. # returns True if given stream is parsable as xxx
  75. .. admonition:: Excluding Support
  76. If the format excludes support for an import/export mechanism (*e.g.*
  77. :class:`csv <tablib.Dataset.csv>` excludes
  78. :class:`Databook <tablib.Databook>` support),
  79. simply don't define the respective functions.
  80. Appropriate errors will be raised.
  81. 2. Add your new format module to the :class:`tablib.formats.available` tuple.
  82. 3. Add a mock property to the :class:`Dataset <tablib.Dataset>` class with verbose `reStructured Text`_ docstring.
  83. This alleviates IDE confusion, and allows for pretty auto-generated Sphinx_ documentation.
  84. 4. Write respective :ref:`tests <testing>`.
  85. .. _testing:
  86. --------------
  87. Testing Tablib
  88. --------------
  89. Testing is crucial to Tablib's stability.
  90. This stable project is used in production by many companies and developers,
  91. so it is important to be certain that every version released is fully operational.
  92. When developing a new feature for Tablib, be sure to write proper tests for it as well.
  93. When developing a feature for Tablib,
  94. the easiest way to test your changes for potential issues is to simply run the test suite directly.
  95. .. code-block:: console
  96. $ tox
  97. ----------------------
  98. Continuous Integration
  99. ----------------------
  100. Every pull request is automatically tested and inspected upon receipt with `Travis CI`_.
  101. If you broke the build, you will receive an email accordingly.
  102. Anyone may view the build status and history at any time.
  103. https://travis-ci.org/jazzband/tablib
  104. Additional reports will also be included here in the future, including :pep:`8` checks and stress reports for extremely large datasets.
  105. .. _`Travis CI`: https://travis-ci.org/
  106. .. _docs:
  107. -----------------
  108. Building the Docs
  109. -----------------
  110. Documentation is written in the powerful, flexible,
  111. and standard Python documentation format, `reStructured Text`_.
  112. Documentation builds are powered by the powerful Pocoo project, Sphinx_.
  113. The :ref:`API Documentation <api>` is mostly documented inline throughout the module.
  114. The Docs live in ``tablib/docs``.
  115. In order to build them, you will first need to install Sphinx.
  116. .. code-block:: console
  117. $ pip install sphinx
  118. Then, to build an HTML version of the docs, simply run the following from the ``docs`` directory:
  119. .. code-block:: console
  120. $ make html
  121. Your ``docs/_build/html`` directory will then contain an HTML representation of the documentation,
  122. ready for publication on most web servers.
  123. You can also generate the documentation in **epub**, **latex**, **json**, *&c* similarly.
  124. .. _`reStructured Text`: http://docutils.sourceforge.net/rst.html
  125. .. _Sphinx: http://sphinx.pocoo.org
  126. .. _`GitHub Pages`: https://pages.github.com
  127. ----------
  128. Make sure to check out the :ref:`API Documentation <api>`.