Skip to content

Commit 052f02e

Browse files
committed
Add documentation for using as library #3130
Signed-off-by: Chin Yeung Li <tli@nexb.com>
1 parent 08630ab commit 052f02e

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

docs/source/getting-started/install.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ For more information on Python virtualenv, visit this
423423
no default dependencies on pre-built binaries. This may come handy for some
424424
special use cases such as packaging for a Linux or FreeBSD distro.
425425

426+
.. NOTE::
427+
428+
Refer :ref:`run_as_library` for usage samples.
429+
426430

427431
To uninstall, run::
428432

docs/source/how-to-guides/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
add_new_license
1515
add_new_license_detection_rule
1616
install_new_license_plugin
17+
run_as_library
1718
generate_attribution
1819
how_to_add_a_post_scan_plugin
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.. _run_as_library:
2+
3+
Run as Library
4+
==============
5+
6+
If you’ve installed ScanCode-Toolkit as a library (:ref:`pip_install`), you
7+
can directly import it into your Python scripts.
8+
9+
ScanCode-Toolkit offers a wide range of callable functions. Each function
10+
includes in-code documentation. Users can refer to it to understand the
11+
purpose of each function, then import and use the ones they need.
12+
13+
While listing them all isn't feasible, here are a few sample use cases.
14+
15+
To Run a Scan
16+
-------------
17+
18+
::
19+
20+
from scancode.cli import run_scan
21+
22+
23+
See https://github.com/aboutcode-org/scancode-toolkit/blob/develop/src/scancode/cli.py#L535
24+
25+
26+
Get YAML Safe Text
27+
------------------
28+
29+
::
30+
31+
from licensedcode.models import get_yaml_safe_text
32+
33+
34+
See https://github.com/aboutcode-org/scancode-toolkit/blob/develop/src/licensedcode/models.py#L777
35+
36+
37+
.. NOTE::
38+
39+
For more sample usages, refer https://github.com/nexB/scancode.io/blob/main/scanpipe/pipes/scancode.py

0 commit comments

Comments
 (0)