Skip to content

Commit 541c985

Browse files
committed
[misc] doc generation addition
1 parent cadd826 commit 541c985

19 files changed

+2346
-6
lines changed

.github/workflows/release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Generate Docs and Update Documentation Repository
2+
3+
on:
4+
push:
5+
workflow_dispatch: # Allow manual triggering
6+
7+
jobs:
8+
update-docs:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout Python project
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install dependencies
23+
run: |
24+
# Install your project dependencies
25+
pip install -r docs/requirements.txt
26+
pip install -e .
27+
28+
- name: Generate Sphinx documentation
29+
run: |
30+
sphinx-build -b markdown docs/source docs/_build/markdown
31+
32+
- name: Checkout documentation repository
33+
uses: actions/checkout@v4
34+
with:
35+
repository: rusher/mariadb-docs # Replace with actual repo
36+
token: ${{ secrets.DOCS_REPO_TOKEN }}
37+
path: docs-repo
38+
39+
- name: Update documentation subdirectory
40+
run: |
41+
# Remove existing documentation in target subdirectory
42+
rm -rf docs-repo/mariadb-docs/connectors/mariadb-connector-python/api/*
43+
44+
# Copy new documentation
45+
cp -r docs/_build/markdown/* docs-repo/mariadb-docs/connectors/mariadb-connector-python/api/
46+
47+
# Optional: Add any additional processing here
48+
# e.g., update index files, fix relative links, etc.
49+
50+
- name: Create Pull Request
51+
uses: peter-evans/create-pull-request@v5
52+
with:
53+
token: ${{ secrets.DOCS_REPO_TOKEN }}
54+
path: docs-repo
55+
commit-message: "Update API documentation from ${{ github.repository }}"
56+
title: "Auto-update: API Documentation from ${{ github.repository }}"
57+
body: |
58+
This PR automatically updates the documentation subdirectory with the latest Sphinx-generated markdown from [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}).
59+
60+
**Changes:**
61+
- Updated documentation generated from commit ${{ github.sha }}
62+
- Generated on: ${{ github.run_id }}
63+
64+
branch: auto-docs-update-${{ github.run_number }}
65+
delete-branch: true

.readthedocs.yml

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

88
# Build documentation in the docs/ directory with Sphinx
99
sphinx:
10-
configuration: doc/source/conf.py
10+
configuration: docs/source/conf.py
1111

1212
# Build documentation with MkDocs
1313
#mkdocs:
@@ -16,8 +16,7 @@ sphinx:
1616
# Optionally build your docs in additional formats such as PDF and ePub
1717
formats: all
1818

19-
# Optionally set the version of Python and requirements required to build your docs
20-
#python:
21-
# version: 3.7
22-
# install:
23-
# - requirements: docs/requirements.txt
19+
# Ensure the necessary Python dependencies are installed
20+
python:
21+
install:
22+
- requirements: docs/requirements.txt

docs/examples/basic01.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Import MariaDB Connector/Python module
2+
import mariadb
3+
4+
# connection parameters
5+
conn_params= {
6+
"user" : "example_user",
7+
"password" : "GHbe_Su3B8",
8+
"host" : "localhost",
9+
"database" : "test"
10+
}
11+
12+
# Establish a connection
13+
connection= mariadb.connect(**conn_params)
14+
15+
cursor= connection.cursor()
16+
17+
# Create a database table
18+
cursor.execute("DROP TABLE IF EXISTS mytest")
19+
cursor.execute("CREATE TABLE mytest(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,"
20+
"first_name VARCHAR(100), last_name VARCHAR(100))")
21+
22+
23+
# Populate table with some data
24+
cursor.execute("INSERT INTO mytest(first_name, last_name) VALUES (?,?)",
25+
("Robert", "Redford"))
26+
27+
# retrieve data
28+
cursor.execute("SELECT id, first_name, last_name FROM mytest")
29+
30+
# print content
31+
row= cursor.fetchone()
32+
print(*row, sep='\t')
33+
34+
# free resources
35+
cursor.close()
36+
connection.close()

docs/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sphinx
2+
myst-parser
3+
sphinx-markdown-builder

docs/source/api.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-------------
2+
API Reference
3+
-------------
4+
5+
.. sectionauthor:: Georg Richter <georg@mariadb.com>
6+
7+
.. toctree::
8+
:maxdepth: 2
9+
:caption: Contents:
10+
11+
module
12+
connection
13+
cursor
14+
pool
15+
constants
16+

docs/source/bugs.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Bug reports
2+
===========
3+
4+
If you think that you have found a bug in MariaDB Software, please report it at
5+
`Jira issue tracker <https://jira.mariadb.org>`_ and file it under Project CONPY (abbreviation for Connector/Python).
6+
7+
How to report a bug?
8+
--------------------
9+
10+
Search first
11+
^^^^^^^^^^^^
12+
Always search the bug database first. Especially if you are using an older version of MariaDB Connector/Python it could
13+
be reported already by someone else or it was already fixed in a more recent version.
14+
15+
What?
16+
^^^^^
17+
We need to know what you did, what happened and what you wanted to happen. A report stating that method xyz() hangs, will
18+
not allow us to provide you with an advice or fix, since we just don't know what the method is doing.
19+
Beside versions a good bug report contains a short script which reproduces the problem. Sometimes it is also necessary to
20+
provide the definition (and data) of used tables.
21+
22+
Versions of components
23+
^^^^^^^^^^^^^^^^^^^^^^
24+
MariaDB Connector/Python interacts with two other components: The database server and MariaDB Connector/C. Latter one is responsible for client/server communication. An error does not necessarily have to exist in Connector / Python; it can also be an error in the database server or in Connector/C. In this case we will reclassify the bug (MDEV or CONC).
25+
26+
Avoid screenshots!
27+
^^^^^^^^^^^^^^^^^^
28+
Use copy and paste instead. Screenshots create a lot more data volume and are often difficult to
29+
read on mobile devices. Typing program code from a screenshot is also an unnecessary effort.
30+
31+
Keep it simple!
32+
^^^^^^^^^^^^^^^
33+
Scripts which are longer than 10 lines often contain code which is not relevant to the problem and increases
34+
the time to figure out the real problem. So try to keep it simple and focus on the real problem.
35+
36+
The sane applies for database related components like tables, views and stored procedures. Avoid table definitions with
37+
hundred of columns if the problem can be reproduced with only 4 columns,
38+
39+
Only report one problem in one bug report
40+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41+
If you have encountered two or more bugs which are not related, please file an issue for each of them.
42+
43+
Crashes
44+
^^^^^^^
45+
If your application crashes, please also provide if possible a backtrace and output of the exception.
46+
47+
Report bugs in English only!
48+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

docs/source/conf.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
import mariadb
16+
from typing import Sequence
17+
from datetime import datetime
18+
print(mariadb.__path__)
19+
sys.path.insert(0, os.path.abspath('../..'))
20+
sys.setrecursionlimit(1500)
21+
22+
23+
# -- Project information -----------------------------------------------------
24+
25+
project = 'MariaDB Connector/Python'
26+
copyright = '2019-%s MariaDB Corporation and Georg Richter' % datetime.now().year
27+
author = 'Georg Richter'
28+
29+
# The full version, including alpha/beta/rc tags
30+
release = mariadb.__version__
31+
if len(mariadb.__version_info__) > 3:
32+
release= release + "-" + mariadb.__version_info__[3]
33+
add_module_names= False
34+
35+
36+
# -- General configuration ---------------------------------------------------
37+
38+
# Add any Sphinx extension module names here, as strings. They can be
39+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
40+
# ones.
41+
extensions = ['sphinx.ext.doctest', 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
42+
'sphinx.ext.extlinks', 'sphinx_toolbox.collapse', 'myst_parser', 'sphinx_markdown_builder' ]
43+
44+
# Add any paths that contain templates here, relative to this directory.
45+
templates_path = ['_templates']
46+
47+
# List of patterns, relative to source directory, that match files and
48+
# directories to ignore when looking for source files.
49+
# This pattern also affects html_static_path and html_extra_path.
50+
exclude_patterns = []
51+
52+
pygments_style = 'sphinx'
53+
54+
master_doc = 'index'
55+
56+
# Enable Markdown support via MyST-Parser
57+
source_suffix = {
58+
'.rst': 'restructuredtext',
59+
'.md': 'markdown',
60+
}
61+
62+
# Optional: Enable MyST extensions (customize as needed)
63+
myst_enable_extensions = [
64+
"colon_fence",
65+
"deflist",
66+
"html_admonition",
67+
"html_image",
68+
"linkify",
69+
"substitution",
70+
"tasklist",
71+
]
72+
73+
74+
# -- Options for HTML output -------------------------------------------------
75+
76+
# The theme to use for HTML and HTML Help pages. See the documentation for
77+
# a list of builtin themes.
78+
#
79+
html_theme = 'classic'
80+
81+
# Add any paths that contain custom static files (such as style sheets) here,
82+
# relative to this directory. They are copied after the builtin static files,
83+
# so a file named "default.css" will overwrite the builtin "default.css".
84+
html_static_path = ['_static']
85+
html_show_sourcelink = False
86+
87+
highlight_language = 'python'
88+
89+
rst_epilog="""
90+
.. |MCP| replace:: MariaDB Connector/Python
91+
.. |MCC| replace:: MariaDB Connector/C
92+
.. |MCC_minversion| replace:: 3.3.1
93+
.. |DBAPI| replace:: DB API 2.0 (:PEP:`249`)
94+
.. |MCDP| replace:: `MariaDB Connector Download page <https://mariadb.com/downloads/connectors/>`__
95+
"""
96+
97+
extlinks= {
98+
'conpy' : ('https://jira.mariadb.org/browse/CONPY-%s', 'CONPY-%s'),
99+
'PEP' : ('https://peps.python.org/pep-%s', 'PEP-%s')
100+
}

0 commit comments

Comments
 (0)