Skip to content

Commit 27d1085

Browse files
Update plugins docs and fix links
Reference: #3103 Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent f056c59 commit 27d1085

3 files changed

Lines changed: 72 additions & 16 deletions

File tree

docs/scripts/sphinx_build_link_check.sh

100644100755
File mode changed.

docs/source/misc/faq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Can I install ScanCode in a Unicode path?
6868
-----------------------------------------
6969

7070
Yes but but it is best to void this for now. See
71-
https://github.com/nexB/scancode- toolkit/issues/867
71+
https://github.com/nexB/scancode-toolkit/issues/867
7272

7373
There is a bug in virtualenv https://github.com/pypa/virtualenv/issues/457 that
7474
is now fixed but has not been extensively tested for ScanCode.

docs/source/tutorials/how_to_add_a_post_scan_plugin.rst

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,71 @@
33
Add A Post-Scan Plugin
44
======================
55

6+
Scan plugins in ``scancode-toolkit``
7+
------------------------------------
8+
9+
A lot of scancode features are built-in plugins which are present with scancode-toolkit source code
10+
and are usually enabled via the different scancode-toolkit CLI options and are grouped by the types
11+
of plugins.
12+
13+
Here are the major types of plugins:
14+
15+
1. Pre-scan plugins (`scancode_pre_scan` in entry points)
16+
17+
These plugins are run before the main scanning steps and are usually
18+
filtering of input files, or file classification steps, on whose results
19+
the main scan plugins depend on. The base plugin class to be extended is ``PreScanPlugin`` at
20+
`/src/plugincode/pre_scan.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/pre_scan.py>`_.
21+
22+
2. Scan plugins (`scancode_scan` in entry points)
23+
24+
The are the scancode plugins which does the file scanning for useful
25+
information like license, copyrights, packages and others. These are
26+
run on multiprocessing for speed as they are done on a per-file basis,
27+
but there can also be post-processing steps on these which are run afterwards
28+
and have access to all the per-file scan results. The base plugin class to be extended is
29+
``ScanPlugin`` at `/src/plugincode/scan.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/scan.py>`_.
30+
31+
3. Post-scan plugins (`scancode_post_scan` in entry points)
32+
33+
These are mainly data processing, summerizing and reporting plugins which
34+
depend on all the results for the scan plugins. These add new codebase level
35+
or file-level attributes, and even removes/modifies data as required
36+
for consolidation or summarization. The base plugin class to be extended is ``PostScanPlugin``
37+
at `/src/plugincode/post_scan.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/post_scan.py>`_.
38+
39+
4. Output plugins (`scancode_output` in entry points)
40+
41+
Supported output options in scancode-toolkit are all plugins and
42+
these can also be multiple output options selected. These convert, process
43+
and writes the data in the specific file format as the output of the scanning
44+
procedures. The base plugin class to be extended is ``OutputPlugin`` at
45+
`/src/plugincode/output.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/output.py>`_.
46+
47+
5. Output Filter Plugins (`scancode_output_filter` in entry points)
48+
49+
There are also output filter plugins which apply filters to the outputs
50+
and is modified. These filters can be based on whether resources had any
51+
detections, ignorables present in licenses and others.
52+
The base plugin class to be extended is ``OutputFilterPlugin`` at
53+
`/src/plugincode/output_filter.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/output_filter.py>`_.
54+
55+
6. Location Provider Plugins
56+
57+
These plugins provide pre-built binary libraries and utilities and their locations which
58+
are packaged to be used in scancode-toolkit. The base plugin class to be extended is
59+
``LocationProviderPlugin`` at `/src/plugincode/location_provider.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/location_provider.py>`_.
60+
61+
662
Built-In vs. Optional Installation
763
----------------------------------
864

965
Built-In
1066
^^^^^^^^
1167

12-
Some post-scan plugins are installed when ScanCode itself is installed, e.g., the
13-
:ref:`license_policy_plugin`, whose code is located here::
68+
Some post-scan plugins are installed when ScanCode itself is installed, and they are specified at
69+
``[options.entry_points]`` in the `setup.cfg <https://github.com/nexB/scancode-toolkit/blob/develop/setup.cfg>`_ file.
70+
For example, the :ref:`license_policy_plugin` is a built-in plugin, whose code is located here::
1471

1572
https://github.com/nexB/scancode-toolkit/blob/develop/src/licensedcode/plugin_license_policy.py
1673

@@ -23,7 +80,7 @@ Optional
2380
ScanCode is also designed to use post-scan plugins that must be installed separately from the
2481
installation of ScanCode. The code for this sort of plugin is located here::
2582

26-
https://github.com/nexB/scancode-toolkit/tree/develop/plugins/
83+
https://github.com/nexB/scancode-plugins
2784

2885
This wiki page will focus on optional post-scan plugins.
2986

@@ -45,26 +102,25 @@ We'll start by creating three folders:
45102
1. Top-level folder -- ``/scancode-hello/``
46103
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47104

48-
- In the ``/scancode-toolkit/plugins/`` directory, add a folder with a relevant name, e.g.,
49-
``scancode-hello``. This folder will hold all of your plugin code.
105+
- In the ``scancode-plugins`` repository, in the ``misc`` directory, add a folder with
106+
a relevant name, e.g., ``scancode-hello``. This folder will hold all of your plugin code.
50107

51108
- Inside the ``/scancode-hello/`` folder you'll need to add a folder named ``src`` and 7 files.
52-
53-
1. ``/src/`` -- This folder will contain your primary Python code and is discussed in more detail
54-
in the following section.
109+
``/src/`` -- This folder will contain your primary Python code and is discussed in more detail
110+
in the following section.
55111

56112
The 7 Files are:
57113

58114
1. ``.gitignore`` -- See, e.g.,
59-
`/plugins/scancode-ignore-binaries/.gitignore <https://github.com/nexB/scancode-toolkit/blob/develop/plugins/scancode-ignore-binaries/.gitignore>`_
115+
`/scancode-ignore-binaries/.gitignore <https://github.com/nexB/scancode-plugins/blob/main/misc/scancode-ignore-binaries/.gitignore>`_
60116

61117
::
62118

63119
/build/
64120
/dist/
65121

66122
2. ``apache-2.0.LICENSE`` -- See, e.g.,
67-
`/plugins/scancode-ignore-binaries/apache-2.0.LICENSE <https://github.com/nexB/scancode-toolkit/blob/develop/plugins/scancode-ignore-binaries/apache-2.0.LICENSE>`_
123+
`/scancode-ignore-binaries/apache-2.0.LICENSE <https://github.com/nexB/scancode-plugins/blob/main/misc/scancode-ignore-binaries/apache-2.0.LICENSE>`_
68124

69125
3. ``MANIFEST.in``
70126

@@ -83,7 +139,7 @@ The 7 Files are:
83139
global-exclude *.py[co] __pycache__ *.*~
84140

85141
4. ``NOTICE`` -- See, e.g.,
86-
`/plugins/scancode-ignore-binaries/NOTICE <https://github.com/nexB/scancode-toolkit/blob/develop/plugins/scancode-ignore-binaries/NOTICE>`__
142+
`/scancode-ignore-binaries/NOTICE <https://github.com/nexB/scancode-plugins/blob/main/misc/scancode-ignore-binaries/NOTICE>`__
87143

88144
5. ``README.md``
89145

@@ -129,7 +185,7 @@ The 7 Files are:
129185
long_description=desc,
130186
author='nexB',
131187
author_email='info@aboutcode.org',
132-
url='https://github.com/nexB/scancode-toolkit/plugins/scancode-categories',
188+
url='https://github.com/nexB/scancode-plugins/blob/main/misc/scancode-hello/',
133189
packages=find_packages('src'),
134190
package_dir={'': 'src'},
135191
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
@@ -201,11 +257,11 @@ Create a ``PostScanPlugin`` class
201257
"""""""""""""""""""""""""""""""""
202258

203259
The ``PostScanPlugin`` class
204-
`PostScanPlugin code <https://github.com/nexB/scancode-toolkit/blob/develop/src/plugincode/post_scan.py>`_)
260+
`PostScanPlugin code <https://github.com/nexB/plugincode/blob/main/src/plugincode/post_scan.py>`_)
205261
inherits from the ``CodebasePlugin`` class (see
206-
`CodebasePlugin code <https://github.com/nexB/scancode-toolkit/blob/794d7acf78480823084def703b5d61ade12efdf2/src/plugincode/__init__.py#L139-L150>`_),
262+
`CodebasePlugin code <https://github.com/nexB/plugincode/blob/main/src/plugincode/__init__.py>`_),
207263
which inherits from the ``BasePlugin`` class (see
208-
`BasePlugin code <https://github.com/nexB/scancode-toolkit/blob/794d7acf78480823084def703b5d61ade12efdf2/src/plugincode/__init__.py#L38-L136>`_).
264+
`BasePlugin code <https://github.com/nexB/plugincode/blob/main/src/plugincode/__init__.py>`_).
209265

210266
::
211267

0 commit comments

Comments
 (0)