Skip to content

Commit faea9fc

Browse files
authored
Merge pull request #33 from AyanSinhaMahapatra/update-docs
Add Final Improvements/Changes before Migrating
2 parents 7229d3e + 214b8e8 commit faea9fc

40 files changed

Lines changed: 1304 additions & 220 deletions

docs/source/aboutcode-docs/writing_good_commit_messages.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _good_commit_messages:
2+
13
Writing good Commit Messages
24
============================
35

docs/source/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@
3636
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3737
# ones.
3838
extensions = [
39+
'sphinx.ext.intersphinx'
3940
]
4041

42+
# Temporary Mapping, Once scancode-toolkit.readthedocs.io has the migrated docs, this can be changed to the same.
43+
intersphinx_mapping = {'scancode-toolkit': ('https://sphinx-test-ayan.readthedocs.io/en/scancode-toolkit/', None)}
44+
4145
# Add any paths that contain templates here, relative to this directory.
4246
templates_path = ['_templates']
4347

docs/source/doc_maintenance.rst

Lines changed: 228 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

8794
Share AboutCode Document Improvements
8895
-------------------------------------
@@ -99,11 +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.
320+
321+
Converting from Markdown
322+
------------------------
104323

105-
Documentation Style Guides
106-
--------------------------
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.
107327

108-
The ``scancode-toolkit`` documentation is compliant to our doc style standards, enforced using
109-
``doc8``. For more details refer :ref:`contrib_doc_dev`.
328+
This will be helpful in converting GitHub wiki's (Markdown Files) to reStructuredtext files for
329+
Sphinx/ReadTheDocs hosting.

docs/source/index.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ Documentation Guide
2525
doc_maintenance
2626

2727

28+
Getting Started
29+
***************
30+
31+
.. toctree::
32+
:maxdepth: 2
33+
34+
scancode-toolkit/getting-started/newcomer
35+
2836
Tutorial Documents
2937
******************
3038

@@ -65,3 +73,7 @@ Indices and Tables
6573

6674
* :ref:`genindex`
6775
* :ref:`modindex`
76+
77+
.. _improve_docs:
78+
79+
.. include:: /scancode-toolkit/rst_snippets/improve_docs.rst

docs/source/scancode-toolkit/cli-reference/basic-options.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55

66
----
77

8+
.. include:: /scancode-toolkit/rst_snippets/note_snippets/synopsis_install_quickstart.rst
9+
10+
----
11+
812
``--generated`` Options
913
-----------------------
1014

1115
The ``--generated`` option classifies automatically generated code files with a flag.
1216

1317
An example of using ``--generated`` in a scan::
1418

15-
./scancode -clpieu --json-pp output.json samples --generated
19+
scancode -clpieu --json-pp output.json samples --generated
1620

1721
In the results, for each file the following attribute is added with it's corresponding
1822
``true``/``false`` value ::
@@ -47,7 +51,7 @@
4751

4852
An example usage::
4953

50-
./scancode -clpieu --json-pp output.json samples --max-email 5
54+
scancode -clpieu --json-pp output.json samples --max-email 5
5155

5256
This only reports 5 email addresses per file and ignores the rest.
5357

@@ -71,7 +75,7 @@
7175

7276
An example usage::
7377

74-
./scancode -clpieu --json-pp output.json samples --max-url 10
78+
scancode -clpieu --json-pp output.json samples --max-url 10
7579

7680
This only reports 10 urls per file and ignores the rest.
7781

@@ -100,7 +104,7 @@
100104

101105
An example usage::
102106

103-
./scancode -clpieu --json-pp output.json samples --license-score 70
107+
scancode -clpieu --json-pp output.json samples --license-score 70
104108

105109
Here's the license results on setting the integer value to 100, Vs. the default value 0. This is
106110
visualized using ScanCode workbench in the License Info Dashboard.
@@ -134,7 +138,7 @@
134138

135139
An example Scan::
136140

137-
./scancode -cplieu --json-pp output.json samples --license-text
141+
scancode -cplieu --json-pp output.json samples --license-text
138142

139143
An example matched text included in the results is as follows::
140144

@@ -178,7 +182,7 @@
178182

179183
A scan example using the ``--license-url-template TEXT`` option ::
180184

181-
./scancode -clpieu --json-pp output.json samples --license-url-template https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/{}.yml
185+
scancode -clpieu --json-pp output.json samples --license-url-template https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/{}.yml
182186

183187
In a normal scan, reference url for "ZLIB License" is as follows::
184188

@@ -212,7 +216,7 @@
212216

213217
An example Scan::
214218

215-
./scancode -cplieu --json-pp output.json samples --license-text --license-text-diagnostics
219+
scancode -cplieu --json-pp output.json samples --license-text --license-text-diagnostics
216220

217221
Running a scan on the samples directory with ``--license-text --license-text-diagnostics`` options,
218222
causes the following difference in the scan result of the file

docs/source/scancode-toolkit/cli-reference/core-options.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
----
99

10+
.. include:: /scancode-toolkit/rst_snippets/note_snippets/synopsis_install_quickstart.rst
11+
12+
----
13+
1014
Comparing Progress Message Options
1115
----------------------------------
1216

@@ -89,7 +93,7 @@ Comparing Progress Message Options
8993

9094
An example scan command using ``--from-json``::
9195

92-
./scancode --from-json sample.json --json-pp sample_2.json --classify
96+
scancode --from-json sample.json --json-pp sample_2.json --classify
9397

9498
This inputs the scan results from ``sample.json``, runs the post-scan plugin ``--classify`` and
9599
outputs the results for this scan to ``sample_2.json``.
@@ -114,4 +118,4 @@ Comparing Progress Message Options
114118

115119
An example usage::
116120

117-
./scancode -clieu --json-pp sample.json samples --max-in-memory -1
121+
scancode -clieu --json-pp sample.json samples --max-in-memory -1

0 commit comments

Comments
 (0)