sphinx_biel 0.1.0__py2.py3-none-any.whl

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,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)
@@ -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,5 @@
1
+ sphinx_biel/__init__.py,sha256=i0IDFLtzhpb6YaKU1Pv0z6ffIPVZf0NOEtjqM3tjFlk,3090
2
+ sphinx_biel-0.1.0.dist-info/LICENSE.md,sha256=Iswh4l-k6fOZeKmtFbDd_bJjuVOgNJcKJZ7uAVZrUv8,1051
3
+ sphinx_biel-0.1.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
4
+ sphinx_biel-0.1.0.dist-info/METADATA,sha256=Q5_VGFPHNn2fBT4gUb5FZq5nVXBqlAmiCEXtUvjkYU0,1418
5
+ sphinx_biel-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: flit 3.9.0
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any