development.rst 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. If you'd like to contribute, there's plenty to do. Here's a short todo list.
  8. .. include:: ../TODO.rst
  9. .. _GitHub: http://github.com/kennethreitz/tablib/
  10. .. _design:
  11. ---------------------
  12. Design Considerations
  13. ---------------------
  14. Tablib was developed with a few :pep:`20` idioms in mind.
  15. #. Beautiful is better than ugly.
  16. #. Explicit is better than implicit.
  17. #. Simple is better than complex.
  18. #. Complex is better than complicated.
  19. #. Readability counts.
  20. A few other things to keep in mind:
  21. #. Keep your code DRY.
  22. #. Strive to be as simple (to use) as possible.
  23. .. _scm:
  24. --------------
  25. Source Control
  26. --------------
  27. Tablib source is controlled with Git_, the lean, mean, distributed source
  28. control machine.
  29. The repository is publicly accessible.
  30. ``git clone git://github.com/kennethreitz/tablib.git``
  31. The project is hosted on **GitHub**.
  32. GitHub:
  33. http://github.com/kennethreitz/tablib
  34. Git Branch Structure
  35. ++++++++++++++++++++
  36. Feature / Hotfix / Release branches follow a `Successful Git Branching Model`_ . Git-flow_ is a great tool for managing the repository. I highly recommend it.
  37. ``develop``
  38. The "next release" branch. Likely unstable.
  39. ``master``
  40. Current production release (|version|) on PyPi.
  41. ``gh-pages``
  42. Current release of http://docs.python-tablib.org.
  43. Each release is tagged.
  44. When submitting patches, please place your feature/change in its own branch prior to opening a pull request on GitHub_.
  45. .. _Git: http://git-scm.org
  46. .. _`Successful Git Branching Model`: http://nvie.com/posts/a-successful-git-branching-model/
  47. .. _git-flow: http://github.com/nvie/gitflow
  48. .. _newformats:
  49. ------------------
  50. Adding New Formats
  51. ------------------
  52. Tablib welcomes new format additions! Format suggestions include:
  53. * Tab Separated Values
  54. * MySQL Dump
  55. * HTML Table
  56. Coding by Convention
  57. ++++++++++++++++++++
  58. Tablib features a micro-framework for adding format support. The easiest way to understand it is to use it. So, let's define our own format, named *xxx*.
  59. 1. Write a new format interface.
  60. :class:`tablib.core` follows a simple pattern for automatically utilizing your format throughout Tablib. Function names are crucial.
  61. Example **tablib/formats/_xxx.py**: ::
  62. title = 'xxx'
  63. def export_set(dset):
  64. ....
  65. # returns string representation of given dataset
  66. def export_book(dbook):
  67. ....
  68. # returns string representation of given databook
  69. def import_set(dset, in_stream):
  70. ...
  71. # populates given Dataset with given datastream
  72. def import_book(dbook, in_stream):
  73. ...
  74. # returns Databook instance
  75. def detect(stream):
  76. ...
  77. # returns True if given stream is parsable as xxx
  78. .. admonition:: Excluding Support
  79. If the format excludes support for an import/export mechanism (*eg.* :class:`csv <tablib.Dataset.csv>` excludes :class:`Databook <tablib.Databook>` support), simply don't define the respective functions. Appropriate errors will be raised.
  80. 2.
  81. Add your new format module to the :class:`tablib.formats.available` tuple.
  82. 3.
  83. Add a mock property to the :class:`Dataset <tablib.Dataset>` class with verbose `reStructured Text`_ docstring. 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. This stable project is used in production by many companies and developers, so it is important to be certain that every version released is fully operational. When developing a new feature for Tablib, be sure to write proper tests for it as well.
  90. When developing a feature for Tablib, the easiest way to test your changes for potential issues is to simply run the test suite directly. ::
  91. $ ./test_tablib.py
  92. `Jenkins CI`_, amongst other tools, supports Java's xUnit testing report format. Nose_ allows us to generate our own xUnit reports.
  93. Installing nose is simple. ::
  94. $ pip install nose
  95. Once installed, we can generate our xUnit report with a single command. ::
  96. $ nosetests test_tablib.py --with-xunit
  97. This will generate a **nosetests.xml** file, which can then be analyzed.
  98. .. _Nose: http://somethingaboutorange.com/mrl/projects/nose/
  99. .. _jenkins:
  100. ----------------------
  101. Continuous Integration
  102. ----------------------
  103. Every commit made to the **develop** branch is automatically tested and inspected upon receipt with `Travis CI`_. If you have access to the main repository and broke the build, you will receive an email accordingly.
  104. Anyone may view the build status and history at any time.
  105. https://travis-ci.org/kennethreitz/tablib
  106. Additional reports will also be included here in the future, including :pep:`8` checks and stress reports for extremely large datasets.
  107. .. _`Jenkins CI`: https://travis-ci.org/
  108. .. _docs:
  109. -----------------
  110. Building the Docs
  111. -----------------
  112. Documentation is written in the powerful, flexible, and standard Python documentation format, `reStructured Text`_.
  113. Documentation builds are powered by the powerful Pocoo project, Sphinx_. The :ref:`API Documentation <api>` is mostly documented inline throughout the module.
  114. The Docs live in ``tablib/docs``. In order to build them, you will first need to install Sphinx. ::
  115. $ pip install sphinx
  116. Then, to build an HTML version of the docs, simply run the following from the **docs** directory: ::
  117. $ make html
  118. Your ``docs/_build/html`` directory will then contain an HTML representation of the documentation, ready for publication on most web servers.
  119. You can also generate the documentation in **epub**, **latex**, **json**, *&c* similarly.
  120. .. admonition:: GitHub Pages
  121. To push the documentation up to `GitHub Pages`_, you will first need to run `sphinx-to-github`_ against your ``docs/_build/html`` directory.
  122. GitHub Pages are powered by an HTML generation system called Jekyll_, which is configured to ignore files and folders that begin with "``_``" (*ie.* **_static**).
  123. and `sphinx-to-github`_. ::
  124. Installing sphinx-to-github is simple. ::
  125. $ pip install sphinx-to-github
  126. Running it against the docs is even simpler. ::
  127. $ sphinx-to-github _build/html
  128. Move the resulting files to the **gh-pages** branch of your repository, and push it up to GitHub.
  129. .. _`reStructured Text`: http://docutils.sourceforge.net/rst.html
  130. .. _Sphinx: http://sphinx.pocoo.org
  131. .. _`GitHub Pages`: http://pages.github.com
  132. .. _Jekyll: http://github.com/mojombo/jekyll
  133. .. _`sphinx-to-github`: http://github.com/michaeljones/sphinx-to-github
  134. ----------
  135. Make sure to check out the :ref:`API Documentation <api>`.