Skip to content

Commit 32c9a76

Browse files
authored
Merge pull request #10 from sphinx-notes/feat/auto-append
feat: Auto append comment thread to documents
2 parents 08e4cb7 + 08e0b39 commit 32c9a76

11 files changed

Lines changed: 235 additions & 245 deletions

File tree

.cruft.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/sphinx-notes/cookiecutter",
3-
"commit": "c4f14dab2840eeff6352647a923642b6377d1f49",
3+
"commit": "e9395e52b94aa56ef6e2e309df6ef3c2ab877b43",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -14,7 +14,8 @@
1414
"github_repo": "isso",
1515
"pypi_name": "sphinxnotes-isso",
1616
"pypi_owner": "SilverRainZ",
17-
"_template": "https://github.com/sphinx-notes/cookiecutter"
17+
"_template": "https://github.com/sphinx-notes/cookiecutter",
18+
"_commit": "e9395e52b94aa56ef6e2e309df6ef3c2ab877b43"
1819
}
1920
},
2021
"directory": null

docs/_templates/confval.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/_templates/example.rst

Lines changed: 0 additions & 31 deletions
This file was deleted.

docs/_templates/version.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ Change Log
1919
2020
Change log here.
2121
22+
Version 2.x
23+
===========
24+
25+
.. version:: 2.0
26+
:date: 2025-02
27+
28+
- Add :confval:`isso_include_patterns` and :confval:`isso_exclude_patterns`
29+
for automaticlly inserting comment thread to the end of document (:pull:`10`)
30+
- INCOMPATIBLE CHANGES: Remove the ``:id:`` option of :rst:dir:`isso` directive
31+
(:pull:`10`)
32+
2233
Version 1.x
2334
===========
2435

docs/conf.py

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -74,49 +74,6 @@
7474

7575
# -- Extensions -------------------------------------------------------------
7676

77-
#
78-
extensions.append('sphinxnotes.any')
79-
from sphinxnotes.any import Schema, Field as F
80-
#
81-
version_schema = Schema('version',
82-
name=F(unique=True, referenceable=True, required=True, form=F.Form.LINES),
83-
attrs={'date': F(referenceable=True)},
84-
content=F(form=F.Form.LINES),
85-
description_template=open('_templates/version.rst', 'r').read(),
86-
reference_template='🏷️{{ title }}',
87-
missing_reference_template='🏷️{{ title }}',
88-
ambiguous_reference_template='🏷️{{ title }}')
89-
confval_schema = Schema('confval',
90-
name=F(unique=True, referenceable=True, required=True, form=F.Form.LINES),
91-
attrs={
92-
'type': F(),
93-
'default': F(),
94-
'choice': F(form=F.Form.WORDS),
95-
'versionadded': F(),
96-
'versionchanged': F(form=F.Form.LINES),
97-
},
98-
content=F(),
99-
description_template=open('_templates/confval.rst', 'r').read(),
100-
reference_template='⚙️{{ title }}',
101-
missing_reference_template='⚙️{{ title }}',
102-
ambiguous_reference_template='⚙️{{ title }}')
103-
example_schema = Schema('example',
104-
name=F(referenceable=True),
105-
attrs={'style': F()},
106-
content=F(form=F.Form.LINES),
107-
description_template=open('_templates/example.rst', 'r').read(),
108-
reference_template='📝{{ title }}',
109-
missing_reference_template='📝{{ title }}',
110-
ambiguous_reference_template='📝{{ title }}')
111-
#
112-
any_schemas = [
113-
version_schema,
114-
confval_schema,
115-
example_schema,
116-
]
117-
primary_domain = 'any'
118-
#
119-
12077
extensions.append('sphinx.ext.extlinks')
12178
extlinks = {
12279
'issue': ('https://github.com/sphinx-notes/isso/issues/%s', '💬%s'),
@@ -138,14 +95,14 @@
13895
'jinja': ('https://jinja.palletsprojects.com/en/latest/', None),
13996
}
14097

141-
#
14298
extensions.append('sphinxnotes.comboroles')
14399
comboroles_roles = {
144100
'parsed_literal': (['literal'], True),
145101
}
146-
#
147102

148-
#
103+
extensions.append('sphinxnotes.project')
104+
primary_domain = 'any'
105+
149106
# -- Eat your own dog food --------------------------------------------------
150107

151108
# If extensions (or modules to document with autodoc) are in another directory,
@@ -159,4 +116,3 @@
159116
isso_url = 'https://comments.silverrainz.me:30501'
160117

161118
# DOG FOOD CONFIGURATION END
162-
#

docs/conf.rst

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,36 @@ Configuration
66

77
HTTP URL points to your Isso server.
88

9-
The following configuration items are corresponding to `Isso Client Configuration`_,
10-
please use Python's boolean, numeric value instead of string formatted value.
11-
12-
- ``isso_css``
13-
- ``isso_lang``
14-
- ``isso_reply_to_self``
15-
- ``isso_require_author``
16-
- ``isso_require_email``
17-
- ``isso_max_comments_top``
18-
- ``isso_max_comments_nested``
19-
- ``isso_reveal_on_click``
20-
- ``isso_avatar``
21-
- ``isso_avatar_bg``
22-
- ``isso_avatar_fg``
23-
- ``isso_vote``
24-
- ``isso_vote_levels``
25-
- ``isso_feed``
26-
27-
.. _Isso Client Configuration: https://posativ.org/isso/docs/configuration/client/
9+
10+
.. confval:: isso_client_config
11+
12+
A mapping that corresponding to `Isso Client Configuration`_.
13+
14+
.. versionadded:: 2.0
15+
16+
.. _Isso Client Configuration: https://posativ.org/isso/docs/configuration/client/
17+
18+
19+
.. confval:: isso_exclude_patterns
20+
type: list[str]
21+
default: []
22+
23+
A list of `glob-style patterns`_ that should be excluded when inserting Isso
24+
comment thread.
25+
They are matched against the document name (docname).
26+
:confval:`isso_exclude_patterns` has priority over :confval:`isso_include_patterns`.
27+
28+
.. versionadded:: 2.0
29+
30+
.. _glob-style patterns: https://www.sphinx-doc.org/en/master/usage/configuration.html#glob-style-patterns
31+
32+
33+
.. confval:: isso_include_patterns
34+
type: list[str]
35+
default: []
36+
37+
A list of `glob-style patterns`_ that are used to insert Isso comment thread.
38+
They are matched against the document name (docname).
39+
:confval:`isso_exclude_patterns` has priority over :confval:`isso_include_patterns`.
40+
41+
.. versionadded:: 2.0

docs/index.rst

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ Introduction
2828

2929
.. INTRODUCTION START
3030
31-
The extension allows your embedding Isso_ comments in your Sphinx documentation:
31+
The extension allows your embedding Isso_ comments in your Sphinx documentation.
32+
33+
.. note::
34+
35+
Before using this extension, you should already have an Isso server deployed
36+
(`How to deploy a Isso server?`_) and an accessible URL.
3237

3338
.. _Isso: https://isso-comments.de/
39+
.. _How to deploy a Isso server?: https://isso-comments.de/docs/reference/server-config/
3440

3541
.. INTRODUCTION END
3642
@@ -64,18 +70,29 @@ Then, add the extension name to ``extensions`` configuration item in your
6470

6571
.. ADDITIONAL CONTENT START
6672
67-
Set :confval:`isso_url` to the URL of your Isso server.
73+
Set :confval:`isso_url` to the URL of your Isso server
74+
(`How to deploy a Isso server?`_):
6875

6976
.. code-block:: python
7077
7178
isso_url = 'https://HOST:PORT'
7279
73-
And then you can use directive ``isso`` to insert a Isso comment box, see
74-
:doc:`usage` for more details.
80+
There are two ways to add a comment thread to documentation:
81+
82+
1. Use the :confval:`isso_include_patterns` configuration item. For exampele:
83+
84+
.. code:: python
85+
86+
# Enable commenting for all documents
87+
isso_include_patterns = ['**']
88+
89+
2. Use the :rst:dir:`isso` directive, this will only affect the current document.
90+
91+
.. rst-example::
7592

76-
.. example::
93+
.. isso::
7794

78-
.. isso::
95+
See :doc:`usage` for more details.
7996

8097
Feel free to comment~
8198

docs/usage.rst

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,68 @@
22
Usage
33
=====
44

5-
The ``isso`` directive is used to insert a Isso comment box.
6-
Each comment thread is distinguished by Isso Thread ID (``data-isso-id``),
7-
which can be specified via the ``id`` option (see below) or via ``:isso-id``
8-
docinfo. If no thread ID given, ``/{docname}`` will be used.
5+
.. note::
96

10-
The directive supports the following options:
7+
Isso only supports rendering **one comment thread on the same page**.
8+
If you insert multiple comment threads on the same page, the extra threads
9+
will display error messages.
1110

12-
:id: (text)
13-
Specify a thread ID, optional
14-
:title: (text)
15-
Specify a thread title rather than use document title
11+
There are two ways to insert comment thread:
1612

17-
Enable comments for all documents
18-
=================================
13+
Manual insert (at a specific location)
14+
--------------------------------------
1915

20-
Use Sphinx's ``rst_epilog`` confval to append the ``isso`` directive at the
21-
end of every source file. For example:
16+
.. rst:directive:: .. isso:: [id]
2217
23-
.. code:: python
18+
Insert a Isso comment thread at a specific location.
2419

25-
rst_epilog = """
26-
.. isso::
27-
"""
20+
Threads are distinguished by unique Isso Thread ID (``data-isso-id``),
21+
If no thread ID given, ``/{docname}`` (a slash-prefixed document name)
22+
will be used.
2823

29-
Disable comments for specified document
30-
---------------------------------------
24+
.. rst:directive:option:: title: title
25+
:type: text
3126
32-
This extension respects the ``:nocomments`` docinfo__:
27+
Indicate thread title rather than use original document title.
3328
34-
If set, the web application won’t display a comment form for a page generated
35-
from this source file.
29+
Batch insert (at the end of the document)
30+
-----------------------------------------
3631

37-
__ https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html#file-wide-metadata
32+
If document's docname is matched by :confval:`isso_include_patterns` and
33+
not matched by :confval:`isso_exclude_patterns`, a comment thread will be
34+
automaticlly inserted at the end.
35+
36+
For example:
37+
38+
.. code-block:: python
39+
:caption: Enable commenting for all documents
40+
41+
isso_include_patterns = ['**']
42+
isso_exclude_patterns = []
43+
44+
.. code-block:: python
45+
:caption: Enable commenting for only blog posts
46+
47+
isso_include_patterns = ['blog/**']
48+
49+
.. code-block:: python
50+
:caption: Enable commenting for all documents (except blog posts)
51+
52+
isso_include_patterns = ['**']
53+
isso_exclude_patterns = ['blog/**']
54+
55+
DocInfos
56+
~~~~~~~~
57+
58+
Users can configure the batched inserted comment thread by setting docinfo_:
59+
60+
:``:isso-id``:
61+
Indicate the Isso thread ID, similar to :rst:dir:`isso` directive's argument.
62+
63+
:``:nocomments``:
64+
This extension respects the standard ``:nocomments`` docinfo:
65+
66+
If set, the web application won’t display a comment form for a page generated
67+
from this source file.
68+
69+
.. _docinfo: https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html#file-wide-metadata

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test = [
4646
]
4747
docs = [
4848
"furo",
49-
"sphinxnotes-any",
49+
"sphinxnotes-project",
5050
"sphinx_design",
5151
"sphinx_copybutton",
5252
"sphinxcontrib-gtagjs",

0 commit comments

Comments
 (0)