sphinx_biel 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ [flake8]
2
+ max-line-length = 88
@@ -0,0 +1,13 @@
1
+ version: 2
2
+ updates:
3
+ # Maintain dependencies for GitHub Actions
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "daily"
8
+
9
+ # Maintain dependencies for Poetry
10
+ - package-ecosystem: "pip"
11
+ directory: "/"
12
+ schedule:
13
+ interval: "daily"
@@ -0,0 +1,34 @@
1
+ ---
2
+
3
+ name: CI
4
+
5
+ on:
6
+ push:
7
+ branches: [master]
8
+ pull_request:
9
+ branches: [master]
10
+
11
+ jobs:
12
+ build:
13
+
14
+ runs-on: ubuntu-latest
15
+
16
+ strategy:
17
+ matrix:
18
+ python-version: [3.9, 3.8 ,3.7]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+ - name: "Set up Python"
23
+ uses: actions/setup-python@v4
24
+ with:
25
+ python-version: ${{ matrix.python-version }}
26
+ - name: "Install dependencies"
27
+ run: |
28
+ python -m pip install .[test,doc]
29
+ - name: "Lint code"
30
+ run: |
31
+ pre-commit run --all-files
32
+ - name: "Build sample"
33
+ run: |
34
+ make -C docs dirhtml
@@ -0,0 +1,13 @@
1
+ .coverage
2
+ .DS_Store
3
+ .eggs
4
+ .idea
5
+ .pypirc
6
+ .pytest_cache
7
+ *pyc
8
+ *.egg-info
9
+ coverage.xml
10
+ dist
11
+ docs/build
12
+ __pycache__
13
+ venv
@@ -0,0 +1,26 @@
1
+ repos:
2
+ - repo: https://github.com/pycqa/isort
3
+ rev: 5.10.1
4
+ hooks:
5
+ - id: isort
6
+ name: isort (python)
7
+
8
+ - repo: https://github.com/psf/black
9
+ rev: 22.10.0
10
+ hooks:
11
+ - id: black
12
+ exclude: ^venv/
13
+
14
+ - repo: https://github.com/pycqa/flake8
15
+ rev: '4.0.1'
16
+ hooks:
17
+ - id: flake8
18
+ exclude: ^venv/
19
+
20
+ - repo: https://github.com/pre-commit/pre-commit-hooks
21
+ rev: v4.1.0
22
+ hooks:
23
+ - id: end-of-file-fixer
24
+ - id: trailing-whitespace
25
+ - id: check-yaml
26
+ - id: check-json
@@ -0,0 +1,18 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Build documentation in the docs/ directory with Sphinx
8
+ sphinx:
9
+ configuration: docs/source/conf.py
10
+
11
+ # Optionally build your docs in additional formats such as PDF and ePub
12
+ formats: []
13
+
14
+ # Optionally set the version of Python and requirements required to build your docs
15
+ python:
16
+ version: 3.8
17
+ install:
18
+ - requirements: docs/requirements.txt
@@ -0,0 +1,14 @@
1
+ =========
2
+ Changelog
3
+ =========
4
+
5
+ All notable changes to this project will be documented in this file.
6
+
7
+
8
+ [0.1.0] - 03 August 2023
9
+ ========================
10
+
11
+ Added
12
+ -----
13
+
14
+ * Initial code release
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2023 Biel.ai
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.1
2
+ Name: sphinx_biel
3
+ Version: 0.1.0
4
+ Summary: ASK AI chatbot for Sphinx.
5
+ Author-email: TechDocs Studio <hi@techdocs.studio>
6
+ Description-Content-Type: text/x-rst
7
+ Project-URL: Home, https://github.com/TechDocsStudio/sphinx-biel
8
+
9
+ biel-pushfeedback
10
+ =================
11
+
12
+ ASK AI chatbot for Sphinx documentation sites.
13
+
14
+ Installation
15
+ ------------
16
+
17
+ #. Create a `Biel.ai account <https://biel.ai/>`_.
18
+
19
+ #. Install ``sphinx-biel`` using PIP.
20
+
21
+ .. code-block:: bash
22
+
23
+ pip install sphinx-biel
24
+
25
+ #. Add the extension to your Sphinx project ``conf.py`` file.
26
+
27
+ .. code-block:: python
28
+
29
+ extensions = ['sphinx_biel']
30
+
31
+ #. Configure your project ID in the ``conf.py`` file:
32
+
33
+ .. code-block:: python
34
+
35
+ biel_project = '<YOUR_PROJECT_ID>'
36
+ biel_button_text = 'Ask AI'
37
+ biel_header_title = 'Biel AI Chatbot'
38
+
39
+ Replace ``<YOUR_PROJECT_ID>`` with your project's ID from the `Biel.ai dashboard <https://docs.biel.ai/#2-create-a-project>`_.
40
+
41
+ #. Build the documentation:
42
+
43
+ .. code-block:: bash
44
+
45
+ make html
46
+
47
+ Once built, open your documentation in a web browser. Verify that the chatbot appears and works correctly on your site.
48
+
49
+ For advanced configuration options, see `Sphinx Biel documentation <https://docs.biel.ai/installation/sphinx>`_.
50
+
51
+ License
52
+ -------
53
+
54
+ Copyright (c) 2024 Biel.ai
55
+ Licensed under the `MIT License <https://github.com/TechDocsStudio/sphinx-biel/blob/main/LICENSE.md>`_.
56
+
@@ -0,0 +1,47 @@
1
+ biel-pushfeedback
2
+ =================
3
+
4
+ ASK AI chatbot for Sphinx documentation sites.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ #. Create a `Biel.ai account <https://biel.ai/>`_.
10
+
11
+ #. Install ``sphinx-biel`` using PIP.
12
+
13
+ .. code-block:: bash
14
+
15
+ pip install sphinx-biel
16
+
17
+ #. Add the extension to your Sphinx project ``conf.py`` file.
18
+
19
+ .. code-block:: python
20
+
21
+ extensions = ['sphinx_biel']
22
+
23
+ #. Configure your project ID in the ``conf.py`` file:
24
+
25
+ .. code-block:: python
26
+
27
+ biel_project = '<YOUR_PROJECT_ID>'
28
+ biel_button_text = 'Ask AI'
29
+ biel_header_title = 'Biel AI Chatbot'
30
+
31
+ Replace ``<YOUR_PROJECT_ID>`` with your project's ID from the `Biel.ai dashboard <https://docs.biel.ai/#2-create-a-project>`_.
32
+
33
+ #. Build the documentation:
34
+
35
+ .. code-block:: bash
36
+
37
+ make html
38
+
39
+ Once built, open your documentation in a web browser. Verify that the chatbot appears and works correctly on your site.
40
+
41
+ For advanced configuration options, see `Sphinx Biel documentation <https://docs.biel.ai/installation/sphinx>`_.
42
+
43
+ License
44
+ -------
45
+
46
+ Copyright (c) 2024 Biel.ai
47
+ Licensed under the `MIT License <https://github.com/TechDocsStudio/sphinx-biel/blob/main/LICENSE.md>`_.
@@ -0,0 +1,13 @@
1
+ [build-system]
2
+ requires = ["flit_core >=3.2,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+ module = "src.sphinx_biel"
5
+
6
+ [project]
7
+ name = "sphinx_biel"
8
+ authors = [{name = "TechDocs Studio", email = "hi@techdocs.studio"}]
9
+ readme = "README.rst"
10
+ dynamic = ["version", "description"]
11
+
12
+ [project.urls]
13
+ Home = "https://github.com/TechDocsStudio/sphinx-biel"
@@ -0,0 +1,84 @@
1
+ """
2
+ ASK AI chatbot for Sphinx.
3
+
4
+ (c) 2024 - present Biel.ai
5
+ This code is licensed under MIT license (see LICENSE.md for details).
6
+ """
7
+
8
+ __version__ = "0.1.0"
9
+
10
+ from sphinx.application import Sphinx
11
+
12
+ class BielExtension:
13
+ DEFAULT_OPTIONS = {
14
+ 'button_text': 'Ask AI',
15
+ 'header_title': 'Biel.ai chatbot',
16
+ 'button_style': "dark",
17
+ 'button_position': 'bottom-right',
18
+ 'disable_input': None,
19
+ 'error_message_default': None,
20
+ 'error_message_4_0_3': None,
21
+ 'error_message_4_0_4': None,
22
+ 'expand_modal': None,
23
+ 'footer_text': None,
24
+ 'header_title': None,
25
+ 'hide_expand_button': None,
26
+ 'hide_feedback': None,
27
+ 'initial_messages': None,
28
+ 'modal_position': None,
29
+ 'version': 'latest'
30
+ }
31
+
32
+ def __init__(self, app: Sphinx):
33
+ self.app = app
34
+ self.setup_options()
35
+ self.setup_events()
36
+
37
+ @staticmethod
38
+ def snake_to_kebab(string):
39
+ """Convert snake_case string to kebab-case."""
40
+ return string.replace('_', '-')
41
+
42
+ def inject_biel_scripts(self, app, pagename, templatename, context, doctree):
43
+ version = getattr(app.config, "biel_version", self.DEFAULT_OPTIONS['version'])
44
+ biel_js_module = f'''
45
+ <script type="module" src="https://cdn.jsdelivr.net/npm/biel-search@{version}/dist/biel-search/biel-search.esm.js"></script>
46
+ '''
47
+
48
+ # Add Biel JS module to body
49
+ context.setdefault('body', '')
50
+ context['body'] += biel_js_module
51
+
52
+ if getattr(app.config, "biel_button_position", None) != "default":
53
+ attribute_pairs = [
54
+ f'bielBtn.setAttribute("{self.snake_to_kebab(key)}", "{getattr(app.config, f"biel_{key}")}");'
55
+ for key in self.DEFAULT_OPTIONS.keys() if getattr(app.config, f"biel_{key}") is not None
56
+ ]
57
+ set_attributes_script = "\n ".join(attribute_pairs)
58
+
59
+ button_text = getattr(app.config, "biel_button_text", self.DEFAULT_OPTIONS['button_text'])
60
+
61
+ biel_script = f'''
62
+ <script>
63
+ window.addEventListener('DOMContentLoaded', (event) => {{
64
+ let bielBtn = document.createElement("biel-button");
65
+ bielBtn.innerHTML = "{button_text}";
66
+ {set_attributes_script}
67
+ document.body.appendChild(bielBtn);
68
+ }});
69
+ </script>
70
+ '''
71
+ context['body'] += biel_script
72
+
73
+ def setup_options(self):
74
+ for key in self.DEFAULT_OPTIONS.keys():
75
+ self.app.add_config_value(f'biel_{key}', self.DEFAULT_OPTIONS[key], 'html')
76
+
77
+ def setup_events(self):
78
+ version = getattr(self.app.config, "biel_version", self.DEFAULT_OPTIONS["version"])
79
+ self.app.add_css_file(f'https://cdn.jsdelivr.net/npm/biel-search@{version}/dist/biel-search/biel-search.css')
80
+ self.app.connect('html-page-context', self.inject_biel_scripts)
81
+
82
+
83
+ def setup(app: Sphinx):
84
+ extension = BielExtension(app)