@@ -32,9 +32,15 @@ Now you can install the dependencies in a virtualenv::
3232
3333 cd aboutcode
3434 virtualenv -p /usr/bin/python3.6 docs-venv
35- source bin/activate
35+ source docs-venv/ bin/activate
3636
37- Now you can install Sphinx and the format theme used by readthedocs::
37+ Now, the following prerequisites are installed
38+
39+ - Sphinx
40+ - sphinx_rtd_theme (the format theme used by ReadTheDocs)
41+ - docs8 (style linter)
42+
43+ ::
3844
3945 pip install Sphinx sphinx_rtd_theme doc8
4046
@@ -83,6 +89,7 @@ system before creating a Pull Request.
8389
8490 cd docs
8591 ./scripts/sphinx_build_link_check.sh
92+ ./scripts/doc8_style_check.sh
8693
8794Share AboutCode Document Improvements
8895-------------------------------------
@@ -99,13 +106,224 @@ examples::
99106 git push
100107 git status
101108
102- The AboutCode webhook with ReadTheDocs should rebuild the documentation. You can review your
103- results online.
109+ The AboutCode webhook with ReadTheDocs should rebuild the documentation after your Pull Request
110+ is Merged.
111+
112+ Refer the `Pro Git Book <https://git-scm.com/book/en/v2/ >`_ available online for Git tutorials
113+ covering more complex topics on Branching, Merging, Rebasing etc.
114+
115+ Continuous Integration
116+ ----------------------
117+
118+ The documentations are checked on every new commit through Travis-CI, so that common errors are
119+ avoided and documentation standards are enforced. Travis-CI presently checks for these 3 aspects
120+ of the documentation :
121+
122+ 1. Successful Builds (By using ``sphinx-build ``)
123+ 2. No Broken Links (By Using ``link-check ``)
124+ 3. Linting Errors (By Using ``Doc8 ``)
125+
126+ So run these scripts at your local system before creating a Pull Request::
127+
128+ cd docs
129+ ./scripts/sphinx_build_link_check.sh
130+ ./scripts/doc8_style_check.sh
131+
132+ Style Checks Using ``Doc8 ``
133+ ---------------------------
134+
135+ How To Run Style Tests
136+ ^^^^^^^^^^^^^^^^^^^^^^
137+
138+ In the project root, run the following command::
139+
140+ $ doc8 --max-line-length 100 docs/source/ --ignore D000
141+
142+ A sample output is::
143+
144+ Scanning...
145+ Validating...
146+ docs/source/scancode-toolkit/misc/licence_policy_plugin.rst:37: D002 Trailing whitespace
147+ docs/source/scancode-toolkit/misc/faq.rst:45: D003 Tabulation used for indentation
148+ docs/source/scancode-toolkit/misc/faq.rst:9: D001 Line too long
149+ docs/source/scancode-toolkit/misc/support.rst:6: D005 No newline at end of file
150+ ========
151+ Total files scanned = 34
152+ Total files ignored = 0
153+ Total accumulated errors = 326
154+ Detailed error counts:
155+ - CheckCarriageReturn = 0
156+ - CheckIndentationNoTab = 75
157+ - CheckMaxLineLength = 190
158+ - CheckNewlineEndOfFile = 13
159+ - CheckTrailingWhitespace = 47
160+ - CheckValidity = 1
161+
162+ Now fix the errors and run again till there isn't any style error in the documentation.
163+
164+ What is Checked?
165+ ^^^^^^^^^^^^^^^^
166+
167+ PyCQA is an Organization for code quality tools (and plugins) for the Python programming language.
168+ Doc8 is a sub-project of the same Organization. Refer this `README <https://github.com/PyCQA/doc8/blob/master/README.rst >`_ for more details.
169+
170+ What is checked:
171+
172+ - invalid rst format - D000
173+ - lines should not be longer than 100 characters - D001
174+
175+ - RST exception: line with no whitespace except in the beginning
176+ - RST exception: lines with http or https URLs
177+ - RST exception: literal blocks
178+ - RST exception: rst target directives
179+
180+ - no trailing whitespace - D002
181+ - no tabulation for indentation - D003
182+ - no carriage returns (use UNIX newlines) - D004
183+ - no newline at end of file - D005
184+
185+ Interspinx
186+ ----------
187+
188+ Aboutcode documentation uses `Intersphinx <http://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html >`_
189+ to create links to other Sphinx Documentations, to maintain links to other Aboutcode Projects.
190+
191+ To link sections in the same documentation, standart reST labels are used. Refer
192+ `Cross-Referencing <http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#ref-role >`_ for more information.
193+
194+ For example::
195+
196+ .. _my-reference-label:
197+
198+ Section to cross-reference
199+ --------------------------
200+
201+ This is the text of the section.
202+
203+ It refers to the section itself, see :ref:`my-reference-label`.
204+
205+ Now, using Intersphinx, you can create these labels in one Sphinx Documentation and then referance
206+ these labels from another Sphinx Documentation, hosted in different locations.
207+
208+ You just have to add the following in the ``conf.py `` file for your Sphinx Documentation, where you
209+ want to add the links::
210+
211+ extensions = [
212+ 'sphinx.ext.intersphinx'
213+ ]
214+
215+ intersphinx_mapping = {'scancode-toolkit': ('https://scancode-toolkit.readthedocs.io/en/latest/', None)}
216+
217+ To show all Intersphinx links and their targets of an Intersphinx mapping file, run::
218+
219+ python -msphinx.ext.intersphinx https://scancode-toolkit.readthedocs.io/en/latest/objects.inv
220+
221+ .. WARNING ::
222+
223+ ``python -msphinx.ext.intersphinx https://scancode-toolkit.readthedocs.io/objects.inv `` will
224+ give error.
225+
226+ This enables you to create links to the ``scancode-toolkit `` Documentation in your own
227+ Documentation, where you modified the configuration file. Links can be added like this::
228+
229+ For more details refer :ref:`scancode-toolkit:doc_style_guide`.
230+
231+ You can also not use the ``scancode-toolkit `` label assigned to all links from
232+ scancode-toolkit.readthedocs.io, if you don't have a label having the same name in your Sphinx
233+ Documentation. Example::
234+
235+ For more details refer :ref:`doc_style_guide`.
236+
237+ If you have a label in your documentation which is also present in the documentation linked by
238+ Intersphinx, and you link to that label, it will create a link to the local label.
239+
240+ For more information, refer this tutorial named
241+ `Using Intersphinx <https://my-favorite-documentation-test.readthedocs.io/en/latest/using_intersphinx.html >`_.
242+
243+ Extra Style Checks
244+ ------------------
245+
246+ 1. Headings
247+
248+ (`Refer <http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections >`_)
249+ Normally, there are no heading levels assigned to certain characters as the structure is
250+ determined from the succession of headings. However, this convention is used in Python’s Style
251+ Guide for documenting which you may follow:
252+
253+ # with overline, for parts
254+
255+ * with overline, for chapters
256+
257+ =, for sections
258+
259+ -, for subsections
260+
261+ ^, for sub-subsections
262+
263+ ", for paragraphs
264+
265+ 2. Heading Underlines
266+
267+ Do not use underlines that are longer/shorter than the title headline itself. As in:
268+
269+ ::
270+
271+ Correct :
272+
273+ Extra Style Checks
274+ ------------------
275+
276+ Incorrect :
277+
278+ Extra Style Checks
279+ ------------------------
280+
281+ .. note ::
282+
283+ Underlines shorter than the Title text generates Errors on sphinx-build.
284+
285+
286+ 3. Internal Links
287+
288+ Using ``:ref: `` is advised over standard reStructuredText links to sections (like
289+ ```Section title`_ ``) because it works across files, when section headings are changed, will
290+ raise warnings if incorrect, and works for all builders that support cross-references.
291+ However, external links are created by using the standard ```Section title`_ `` method.
292+
293+ 4. Eliminate Redundancy
294+
295+ If a section/file has to be repeated somewhere else, do not write the exact same section/file
296+ twice. Use ``.. include: ../README.rst `` instead. Here, ``../ `` refers to the documentation
297+ root, so file location can be used accordingly. This enables us to link documents from other
298+ upstream folders.
299+
300+ 5. Using ``:ref: `` only when necessary
301+
302+ Use ``:ref: `` to create internal links only when needed, i.e. it is referenced somewhere.
303+ Do not create references for all the sections and then only reference some of them, because
304+ this created unnecessary references. This also generates ERROR in ``restructuredtext-lint ``.
305+
306+ 6. Spelling
307+
308+ You should check for spelling errors before you push changes. `Aspell <http://aspell.net/ >`_
309+ is a GNU project Command Line tool you can use for this purpose. Download and install Aspell,
310+ then execute ``aspell check <file-name> `` for all the files changed. Be careful about not
311+ changing commands or other stuff as Aspell gives prompts for a lot of them. Also delete the
312+ temporary ``.bak `` files generated. Refer the `manual <http://aspell.net/man-html/ >`_ for more
313+ information on how to use.
314+
315+ 7. Notes and Warning Snippets
316+
317+ Every ``Note `` and ``Warning `` sections are to be kept in ``rst_snippets/note_snippets/ `` and
318+ ``rst_snippets/warning_snippets/ `` and then included to eliminate redundancy, as these are
319+ frequently used in multiple files.
104320
105- .. _doc_style_guide :
321+ Converting from Markdown
322+ ------------------------
106323
107- Documentation Style Guides
108- --------------------------
324+ If you want to convert a ``.md `` file to a ``.rst `` file, this `tool <https://github.com/chrissimpkins/md2rst >`_
325+ does it pretty well. You'd still have to clean up and check for errors as this contains a lot of
326+ bugs. But this is definitely better than converting everything by yourself.
109327
110- The `` scancode-toolkit `` documentation is compliant to our doc style standards, enforced using
111- `` doc8 ``. For more details refer :ref: ` scancode-toolkit:contrib_doc_dev ` .
328+ This will be helpful in converting GitHub wiki's (Markdown Files) to reStructuredtext files for
329+ Sphinx/ReadTheDocs hosting .
0 commit comments