contributing.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. .. _contribute:
  2. Contributing
  3. ------------
  4. Thanks for being curious about contributing!
  5. We greatly appreciate and welcome contributions to this book, be it in the form
  6. of an `issue <https://github.com/datalad-handbook/book/issues/new>`_ or a pull request!
  7. If you are considering doing a pull request: Great! Every contribution is valuable,
  8. from fixing typos to writing full chapters.
  9. The steps below outline how the book "works". It is recommended to also create an issue
  10. to discuss changes or additions you plan to make in advance.
  11. Software setup
  12. """"""""""""""
  13. Depending on the size of your contribution, you may want to be able to build the book
  14. locally to test and preview your changes. If you are fixing typos, tweak the
  15. language, or rewrite a paragraph or two, this shouldn't be necessary, and you can safely
  16. skip this paragraph and instead take a look into the paragraph
  17. `Easy pull requests <contribute#Easy pull requests>`_.
  18. If you want to be able to build the book locally, though, please follow these instructions:
  19. - datalad install the repository recursively. This ensures that dependent subdatasets are installed as well
  20. .. code-block:: bash
  21. datalad install -r https://github.com/datalad-handbook/book.git
  22. - optional, but recommended: Create a virtual environment
  23. .. code-block:: bash
  24. virtualenv --python=python3 ~/env/handbook
  25. . ~/env/handbook/bin/activate
  26. - install the requirements and a custom Python helper for the handbook
  27. .. code-block:: bash
  28. # navigate into the installed dataset
  29. cd book
  30. # install required software
  31. pip install -r requirements.txt
  32. pip install -e .
  33. - install ``librsvg2-bin`` (a tool to render ``.svgs``) with your package manager
  34. .. code-block:: bash
  35. sudo apt-get install librsvg2-bin
  36. Once this is configured, you can build the book locally by running ``make``,
  37. and open it in your browser, for example with ``firefox docs/_build/html/index.html``.
  38. Directives
  39. """"""""""
  40. If you are writing larger sections that contain code, ``gitusernote``\s, ``findoutmore``\s,
  41. or other special directives, please make sure that you read this paragraph.
  42. The book is build with a number of custom directives. If applicable, please
  43. use them in the same way they are used throughout the book.
  44. **Code:** For code that runs
  45. inside a dataset such as ``DataLad-101``, working directories exist. The ``DataLad-101``
  46. dataset for example lives in ``docs/build/wdirs/dl-101``. This comes with the advantage
  47. that code is tested immediately -- if the code snippet contains an error, this error will
  48. be written into the book, and thus prevent faulty commands from being published.
  49. Running code in a working directory will furthermore build up on the existing history
  50. of this dataset, which is very useful if some code relies on working with previously
  51. created content or dataset history. Build code snippets that add to these working directories
  52. by using the ``runrecord`` directive. Commands wrapped in these will write the output
  53. of a command into example files. Make sure to name this files according to the following
  54. schema, because they are executed sequentially:
  55. ``DL-101-1<nr-of-section>-1<nr-of-example>``, e.g.
  56. ``docs/basics/_examples/DL-101-101-101`` for the first example in the first section
  57. of the basics.
  58. Here is how a ``runrecord`` directive can look like:
  59. .. code-block:: rst
  60. .. runrecord:: _examples/DL-101-101-101 # give the path to the resulting file
  61. :language: console
  62. :workdir: dl-101/DataLad-101 # specify a working directory here
  63. # this is a comment
  64. $ this line will be executed
  65. Afterwards, the resulting example files need to be committed into Git. To clear existing
  66. examples and working directory history, run ``make clean`` and ``make clean-examples``.
  67. However, for simple code snippets outside of the narrative of ``DataLad-101``,
  68. simple ``code-block::`` directives are sufficient.
  69. **Other custom directives:** Other custom directives are ``gitusernote``
  70. (for additional Git-related information for Git-users), and ``findoutmore``
  71. (foldable sections that contain content that goes beyond the basics). Make use
  72. of them, if applicable to your contribution.
  73. Easy pull requests
  74. ^^^^^^^^^^^^^^^^^^
  75. The easiest way to do a pull request is within the web-interface that Github
  76. and `readthedocs <https://readthedocs.org>`_ provide. If you visit the rendered
  77. version of the handbook at `handbook.datalad.org <http://handbook.datalad.org/>`_
  78. and click on the small, floating ``v:latest`` element at the lower
  79. right-hand side, the ``Edit`` option will take you straight to an editor that
  80. lets you make your changes and submit a pull request.
  81. .. figure:: img/contrib.png
  82. :figwidth: 100%
  83. :alt: Access the Github interface to submit a pull request right from within
  84. Readthedocs.
  85. You can find an easy way to submit a pull request right from within the handbook.
  86. But you of course are also welcome to submit a pull request with whichever
  87. other workflow suites you best.
  88. Desired structure of the book
  89. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  90. The book consists of three major parts: Introduction, Basics, and Use Cases,
  91. plus an appendix. Purpose and desired content of these parts are outlined
  92. below. When contributing to one of these sections, please make sure that your
  93. contribution stays in the scope of the respective section.
  94. Introduction
  95. """"""""""""
  96. - An introduction to DataLad, and the problems it aims to be a solution for.
  97. - This part is practically free of hands-on content, i.e. no installation
  98. instructions, no demos. Instead, it is about concepts, analogies, general
  99. problems.
  100. - In order to avoid too much of a mental split between a reader's desire to
  101. learn how to actually do things vs. conceptual information, the introduction
  102. is purposefully kept short and serves as a narrated table of contents with
  103. plenty of references to other parts of the book.
  104. Basics
  105. """"""
  106. - This part contains hands-on-style content on skills that are crucial for
  107. using DataLad productively. Any non-essential information is not in basics,
  108. but collected in an appendix.
  109. - The order of topics in this part is determined by the order in which they
  110. become relevant for a novice DataLad user.
  111. - Content should be written in a way that explicitly encourages executing the
  112. shown commands, up to simple challenges (such as: "find out who the author of
  113. the first commit in the installed subdataset XY is").
  114. Use Cases
  115. """""""""
  116. - Topics that do not fit into the introduction or basics parts, but are
  117. DataLad-centric, go into this part.
  118. - Any chapter is written as a more-or-less self-contained document that makes
  119. references to introduction and basics, but only few, and more general ones to
  120. other use cases. This should help with long-term maintenance of the content,
  121. as the specifics of how to approach a particular use case optimally may
  122. evolve over time, and cross-references to specific functionality might
  123. become invalid.
  124. - There is no inherent order in this part, but chapters may be grouped by
  125. domain, skill-level, or DataLad functionality involved (or combinations of
  126. those).
  127. - Any content in this part can deviate from the examples and narrative used for
  128. introduction and basics whenever necessary (e.g. concrete domain specific use
  129. cases). However, if possible, common example datasets, names, terms should be
  130. adopted, and the broadest feasible target audience should be assumed. Such
  131. more generic content should form the early chapters in this part.