Skip to content

Commit 7fead68

Browse files
authored
docs: Use sphinx-js (#248)
1 parent f79633d commit 7fead68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1240
-0
lines changed

.readthedocs.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Build documentation in the docs/ directory with Sphinx
9+
sphinx:
10+
configuration: docs/conf.py
11+
12+
# Optionally set the version of Python and requirements required to build your docs
13+
python:
14+
version: 3.7
15+
install:
16+
- requirements: docs/requirements.txt

docs/CommandCall.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. _CommandCall:
2+
3+
Calling a Command
4+
-----------------
5+
6+
CommandCall API
7+
^^^^^^^^^^^^^^^
8+
.. autoclass:: CommandCall
9+
:members:
10+
11+
.. autofunction:: clOptions
12+
.. autofunction:: shOptions
13+
.. autofunction:: commandCallConfig
14+
15+
Example
16+
^^^^^^^^
17+
18+
Call the RTVJOBA CL command
19+
""""""""""""""""""""""""""""
20+
21+
.. literalinclude:: examples/rtvjoba.js
22+
:language: javascript

docs/Connection.rst

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
.. _Connection:
2+
3+
Creating a Connection
4+
=====================
5+
6+
Transports
7+
----------
8+
9+
The ``Connection`` Class uses ``ODBC``, ``SSH``, ``idb``, and ``REST`` transports to access ``XMLSERVICE``.
10+
Some transports require prerequisite setup. Learn morre about each transport below.
11+
12+
ODBC
13+
^^^^
14+
.. _guide: https://github.com/IBM/ibmi-oss-examples/blob/master/odbc/odbc.md#table-of-contents
15+
16+
The ODBC transport establishes a database connection and calls XMLSERVICE stored procedure.
17+
Refer to the odbc guide_ for setup instructions.
18+
19+
SSH
20+
^^^
21+
The SSH transport executes ``xmlservice-cli`` program via ssh.
22+
Install ``xmlservice-cli`` before using the ``SSH`` transport.
23+
24+
.. code-block:: bash
25+
26+
$ yum install itoolkit-utils
27+
28+
idb
29+
^^^^
30+
31+
The idb transport establishes a database connection and calls the XMLSERVICE stored procedure.
32+
33+
**NOTE** the idb transport is only supported on an IBM i system.
34+
35+
REST
36+
^^^^
37+
The REST transport makes an HTTP request to an endpoint that process the XML input and returns XML output.
38+
39+
Initial configuration is required for the endpoint.
40+
41+
A quick example is to add the following to ``/www/apachedft/conf/httpd.conf``.
42+
43+
44+
.. code-block:: apache
45+
46+
ScriptAlias /cgi-bin/ /QSYS.LIB/XMLSERVICE.LIB/
47+
<Directory /QSYS.LIB/XMLSERVICE.LIB/>
48+
AllowOverride None
49+
Require all granted
50+
SetHandler cgi-script
51+
Options +ExecCGI
52+
</Directory>
53+
54+
Connection API
55+
--------------
56+
57+
.. autoclass:: Connection
58+
:members:
59+
60+
.. autofunction:: connectionConfig
61+
.. autofunction:: odbcOptions
62+
.. autofunction:: sshOptions
63+
.. autofunction:: idbOptions
64+
.. autofunction:: restOptions
65+
.. autofunction:: runCallback
66+
67+
Examples
68+
--------
69+
70+
Creating a ``Connection`` using the ``ODBC`` tranport.
71+
72+
.. code-block:: js
73+
74+
const connection = new Connection({
75+
transport: 'odbc',
76+
transportOptions: { host: 'myhost', username: 'myuser', password: 'mypassword'}
77+
});
78+
79+
Creating a ``Connection`` using the ``ODBC`` tranport with a ``DSN``.
80+
81+
.. code-block:: js
82+
83+
const connection = new Connection({
84+
transport: 'odbc',
85+
transportOptions: { dsn: '*LOCAL'}
86+
});
87+
88+
Creating a ``Connection`` with ``ssh`` tranport using private key to authenticate.
89+
90+
.. code-block:: js
91+
92+
const connection = new Connection({
93+
transport: 'ssh',
94+
transportOptions: { host: 'myhost', username: 'myuser', password: 'mypassword' }
95+
});
96+
97+
Creating a ``Connection`` using the ``ssh`` tranport with a private key to authenticate.
98+
99+
.. code-block:: js
100+
101+
const { readFileSync } = require('fs');
102+
103+
const privateKey = readFileSync('path/to/privateKey', 'utf-8');
104+
105+
// NOTE if your privateKey also requires a passphrase provide it
106+
107+
const connection = new Connection({
108+
transport: 'ssh',
109+
transportOptions: { host: 'myhost', username: 'myuser', privateKey, passphrase: 'myphrase' }
110+
});
111+
112+
Creating a ``Connection`` using the ``idb`` tranport.
113+
114+
.. code-block:: js
115+
116+
const connection = new Connection({
117+
transport: 'idb',
118+
transportOptions: { database: '*LOCAL', username: 'myuser', password: 'mypass' }
119+
});
120+
121+
Creating a ``Connection`` using the ``REST`` tranport.
122+
123+
.. code-block:: js
124+
125+
const connection = new Connection({
126+
transport: 'rest',
127+
transportOptions: {
128+
host: 'myhost',
129+
database: '*LOCAL',
130+
username: 'myuser',
131+
password: 'mypass'
132+
port: 80,
133+
path:'/cgi-bin/xmlcgi.pgm',
134+
}
135+
});

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/ProgramCall.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. _ProgramCall:
2+
3+
Calling a Program or Service Program
4+
------------------------------------
5+
6+
ProgramCall API
7+
^^^^^^^^^^^^^^^
8+
.. autoclass:: ProgramCall
9+
:members:
10+
11+
.. autofunction:: programCallConfig
12+
.. autofunction:: parameterConfig
13+
.. autofunction:: returnConfig
14+
.. autofunction:: data
15+
16+
Example
17+
^^^^^^^^
18+
19+
Call the QUSROBJD Program
20+
"""""""""""""""""""""""""
21+
22+
.. literalinclude:: examples/qusrobjd.js
23+
:language: javascript

docs/conf.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
import json
17+
18+
js_source_path = '../lib'
19+
primary_domain = 'js'
20+
21+
# -- Project information -----------------------------------------------------
22+
23+
project = 'nodejs-itoolkit'
24+
copyright = '2020, IBM'
25+
author = 'IBM'
26+
27+
# The full version, including alpha/beta/rc tags
28+
# read the version from package.json
29+
with open('../package.json', 'r') as read_file:
30+
package = json.load(read_file)
31+
release = package['version']
32+
33+
# -- General configuration ---------------------------------------------------
34+
35+
# Add any Sphinx extension module names here, as strings. They can be
36+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
37+
# ones.
38+
extensions = [
39+
'sphinx_js',
40+
]
41+
42+
# Add any paths that contain templates here, relative to this directory.
43+
templates_path = ['_templates']
44+
45+
# The master toctree document.
46+
master_doc = 'index'
47+
48+
# List of patterns, relative to source directory, that match files and
49+
# directories to ignore when looking for source files.
50+
# This pattern also affects html_static_path and html_extra_path.
51+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
52+
53+
# -- Options for HTML output -------------------------------------------------
54+
55+
# The theme to use for HTML and HTML Help pages. See the documentation for
56+
# a list of builtin themes.
57+
#
58+
html_theme = 'sphinx_rtd_theme'
59+
60+
# Add any paths that contain custom static files (such as style sheets) here,
61+
# relative to this directory. They are copied after the builtin static files,
62+
# so a file named "default.css" will overwrite the builtin "default.css".
63+
html_static_path = ['_static']

docs/deprecated.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. _deprecated:
2+
3+
4+
Deprecated Classes and Functions
5+
================================
6+
7+
.. toctree::
8+
:maxdepth: 1
9+
10+
deprecated/iConn
11+
deprecated/iCmd
12+
deprecated/iDataQueue
13+
deprecated/iNetwork
14+
deprecated/iObj
15+
deprecated/iPgm
16+
deprecated/iProd
17+
deprecated/iQsh
18+
deprecated/iSh
19+
deprecated/iSql
20+
deprecated/iUserSpace
21+
deprecated/iWork
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { Connection, iSql } = require('itoolkit');
2+
const { parseString } = require('xml2js');
3+
4+
const connection = new Connection({
5+
transport: 'ssh',
6+
transportOptions: { host: 'myhost', username: 'myuser', password: 'mypassword' },
7+
});
8+
9+
const sql = new iSql();
10+
11+
sql.addQuery('SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT');
12+
sql.fetch();
13+
sql.free();
14+
15+
connection.add(sql);
16+
17+
connection.run((error, xmlOutput) => {
18+
if (error) {
19+
throw error;
20+
}
21+
parseString(xmlOutput, (parseError, result) => {
22+
if (parseError) {
23+
throw parseError;
24+
}
25+
console.log(JSON.stringify(result));
26+
});
27+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const { Connection, iObj } = require('itoolkit');
2+
3+
const connection = new Connection({
4+
transport: 'ssh',
5+
transportOptions: { host: 'myhost', username: 'myuser', password: 'mypassword' },
6+
});
7+
8+
const obj = new iObj(connection);
9+
10+
obj.addToLibraryList('QHTTPSVR', (error, output) => {
11+
if (error) {
12+
throw error;
13+
}
14+
console.log(output);
15+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const { Connection, iSql } = require('itoolkit');
2+
const { parseString } = require('xml2js');
3+
4+
const connection = new Connection({
5+
transport: 'ssh',
6+
transportOptions: { host: 'myhost', username: 'myuser', password: 'mypassword' },
7+
});
8+
9+
const sql = new iSql();
10+
11+
sql.prepare('call qsys2.tcpip_info()');
12+
sql.execute();
13+
sql.fetch();
14+
sql.free();
15+
16+
connection.add(sql);
17+
18+
connection.run((error, xmlOutput) => {
19+
if (error) {
20+
throw error;
21+
}
22+
parseString(xmlOutput, (parseError, result) => {
23+
if (parseError) {
24+
throw parseError;
25+
}
26+
console.log(JSON.stringify(result));
27+
});
28+
});

0 commit comments

Comments
 (0)