clld-markdown-plugin 1.0.0__tar.gz → 1.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.
@@ -1,39 +1,40 @@
1
- Metadata-Version: 2.1
2
- Name: clld_markdown_plugin
3
- Version: 1.0.0
4
- Summary: Render CLDF markdown in clld apps.
5
- Home-page: https://github.com/clld/clld-markdown-plugin
6
- Author: Robert Forkel, Florian Matter
7
- Author-email: robert_forkel@eva.mpg.de, florianmatter@gmail.com
8
- Project-URL: Bug Tracker, https://github.com/clld/clld-markdown-plugin/issues
1
+ Metadata-Version: 2.4
2
+ Name: clld-markdown-plugin
3
+ Version: 1.1.0
4
+ Summary: A clld plugin to render CLDF markdown in clld apps.
5
+ Author-email: Robert Forkel <dlce.rdm@eva.mpg.de>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/clld/clld-markdown-plugin
8
+ Keywords: web,pyramid,clld
9
9
  Classifier: Development Status :: 5 - Production/Stable
10
- Classifier: Intended Audience :: Science/Research
11
- Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Intended Audience :: Developers
12
11
  Classifier: Natural Language :: English
12
+ Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
14
  Classifier: Programming Language :: Python :: 3.11
17
15
  Classifier: Programming Language :: Python :: 3.12
18
16
  Classifier: Programming Language :: Python :: 3.13
19
17
  Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
+ Requires-Python: >=3.11
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
- Requires-Dist: frontmatter<1.2; python_version < "3.10"
22
+ Requires-Dist: clld>=7.0
23
23
  Requires-Dist: clldutils
24
24
  Requires-Dist: pycldf
25
- Requires-Dist: clld
26
25
  Requires-Dist: markdown
27
26
  Provides-Extra: dev
28
- Requires-Dist: flake8; extra == "dev"
29
- Requires-Dist: twine; extra == "dev"
27
+ Requires-Dist: ruff; extra == "dev"
30
28
  Requires-Dist: wheel; extra == "dev"
31
29
  Requires-Dist: build; extra == "dev"
30
+ Requires-Dist: twine; extra == "dev"
32
31
  Provides-Extra: test
33
- Requires-Dist: pytest; extra == "test"
32
+ Requires-Dist: pytest>=5; extra == "test"
34
33
  Requires-Dist: pytest-mock; extra == "test"
35
34
  Requires-Dist: pytest-cov; extra == "test"
36
- Requires-Dist: tox; extra == "test"
35
+ Requires-Dist: coverage>=4.2; extra == "test"
36
+ Requires-Dist: webtest; extra == "test"
37
+ Dynamic: license-file
37
38
 
38
39
  # clld-markdown-plugin
39
40
 
@@ -0,0 +1,94 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "clld-markdown-plugin"
7
+ version = "1.1.0"
8
+ description = "A clld plugin to render CLDF markdown in clld apps."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ {name = "Robert Forkel", email = "dlce.rdm@eva.mpg.de"}
15
+ ]
16
+ keywords = ["web", "pyramid", "clld"]
17
+ classifiers = [
18
+ "Development Status :: 5 - Production/Stable",
19
+ "Intended Audience :: Developers",
20
+ "Natural Language :: English",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Programming Language :: Python :: 3.15",
28
+ ]
29
+ dependencies = [
30
+ "clld>=7.0",
31
+ "clldutils",
32
+ "pycldf",
33
+ "markdown",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/clld/clld-markdown-plugin"
38
+
39
+ [project.optional-dependencies]
40
+ dev = [
41
+ "ruff",
42
+ "wheel",
43
+ "build",
44
+ "twine",
45
+ ]
46
+ test = [
47
+ "pytest>=5",
48
+ "pytest-mock",
49
+ "pytest-cov",
50
+ "coverage>=4.2",
51
+ "webtest",
52
+ ]
53
+
54
+ [tool.setuptools]
55
+ zip-safe = false
56
+
57
+ [tool.setuptools.packages.find]
58
+ where = ["src"]
59
+
60
+ [tool.ruff]
61
+ line-length = 100
62
+ exclude = [".tox"]
63
+
64
+ [tool.ruff.lint]
65
+ # E/F match default Flake8; D enables pydocstyle checks (since you ignored specific D rules)
66
+ select = ["UP", "N", "C90", "PL", "E", "F", "D"]
67
+ ignore = [
68
+ "D211",
69
+ "D213",
70
+ ]
71
+
72
+ [tool.pytest.ini_options]
73
+ minversion = "5.0"
74
+ testpaths = ["tests"]
75
+ addopts = ["--cov"]
76
+
77
+ [tool.coverage.run]
78
+ source = [
79
+ "clld_markdown_plugin",
80
+ "tests",
81
+ ]
82
+
83
+ [tool.coverage.report]
84
+ show_missing = true
85
+ skip_covered = true
86
+
87
+ [tool.tox]
88
+ requires = ["tox>=4.19"]
89
+ env_list = ["py311", "py312", "py313", "py314", "py315"]
90
+ skip_missing_interpreters = true
91
+
92
+ [tool.tox.env_run_base]
93
+ extras = ["test"]
94
+ commands = [["pytest", { replace = "posargs", default = [], extend = true }]]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,7 +1,7 @@
1
1
  """Top-level package for clld-markdown-plugin."""
2
2
  import logging
3
- from collections.abc import Sequence
4
- from typing import Optional, Callable, Any
3
+ from collections.abc import Sequence, Callable
4
+ from typing import Any
5
5
 
6
6
  from markdown import Markdown
7
7
  from markdown import markdown as base_markdown
@@ -18,12 +18,12 @@ log = logging.getLogger(__name__)
18
18
 
19
19
  __author__ = "Robert Forkel, Florian Matter"
20
20
  __email__ = "robert_forkel@eva.mpg.de, florianmatter@gmail.com"
21
- __version__ = "1.0.0"
21
+ __version__ = "1.1.0"
22
22
  __all__ = ['markdown', 'includeme']
23
23
 
24
24
 
25
- def settings(custom: Optional[dict[str, Any]] = None) -> dict[str, Any]:
26
- """Settings relevant for rendering CLDF Markdown."""
25
+ def settings(custom: dict[str, Any] | None = None) -> dict[str, Any]:
26
+ """Get settings relevant for rendering CLDF Markdown."""
27
27
  def full_spec(spec):
28
28
  return spec if isinstance(spec, dict) else {
29
29
  'route': spec.__name__.split('.')[-1].lower() if spec else '', 'model': spec}
@@ -50,7 +50,7 @@ def settings(custom: Optional[dict[str, Any]] = None) -> dict[str, Any]:
50
50
  "keep_link_labels": False,
51
51
  }
52
52
  custom = custom or {}
53
- for key in res: # pylint: disable=consider-using-dict-items
53
+ for key in res: # noqa: PLC0206
54
54
  if key == 'model_map':
55
55
  for k, v in custom.get(key, {}).items():
56
56
  res[key][k] = full_spec(v)
@@ -64,8 +64,7 @@ def settings(custom: Optional[dict[str, Any]] = None) -> dict[str, Any]:
64
64
 
65
65
 
66
66
  def includeme(config):
67
- """
68
- Called when the plugin is included in a clld app via `config.include('clld_markdown_plugin')`.
67
+ """Call to include the plugin in a clld app `config.include('clld_markdown_plugin')`.
69
68
 
70
69
  Merges default and custom configuration for the plugin in the app's deployment settings under
71
70
  key 'clld_markdown_plugin'.
@@ -88,14 +87,14 @@ def _comma_and_list(entries: Sequence[str], sep1: str = ", ", sep2: str = " and
88
87
  return output + sep2 + entries[-1]
89
88
 
90
89
 
91
- def link_entity( # pylint: disable=R0913,R0917
90
+ def link_entity( # noqa: PLR0917,PLR0913
92
91
  req: ClldRequest,
93
- objid: str,
92
+ objid: str | None,
94
93
  route: str,
95
94
  model: type,
96
95
  session,
97
- decorate: Optional[Callable[[str], str]] = None,
98
- ids: Optional[Sequence[str]] = None,
96
+ decorate: Callable[[str], str] | None = None,
97
+ ids: Sequence[str] | None = None,
99
98
  **kwargs,
100
99
  ) -> str:
101
100
  """Render a CLDF Markdown link as HTML."""
@@ -127,14 +126,49 @@ def render_ex(req: ClldRequest, objid: str, table: str, session, ids=None, **_)
127
126
  return rendered_sentence(session.query(common.Sentence).filter(common.Sentence.id == objid)[0])
128
127
 
129
128
 
129
+ def _repl(
130
+ ml: CLDFMarkdownLink,
131
+ settings_: dict,
132
+ req,
133
+ session,
134
+ source_ids):
135
+ def ref(src): # pragma: no cover
136
+ if WITH_MARKDOWN:
137
+ return base_markdown(src.bibtex().text(markdown=True))
138
+ return src.bibtex().text()
139
+
140
+ table = ml.table_or_fname
141
+ if table in settings_['renderer_map'] and "as_link" not in ml.parsed_url_query:
142
+ return settings_['renderer_map'][table](
143
+ req, ml.objid, table, session or DBSession, **ml.parsed_url_query)
144
+ if table in settings_['model_map']:
145
+ decorate = settings_['model_map'][table].get("decorate", None)
146
+ kw = dict(ml.parsed_url_query.items())
147
+ if ml.label and settings_['keep_link_labels']:
148
+ kw.setdefault('label', [ml.label])
149
+ if table == 'Source':
150
+ if ml.objid != '__all__':
151
+ source_ids.add(ml.objid)
152
+ elif 'cited_only' in ml.parsed_url.query:
153
+ model = settings_['model_map'][table]["model"]
154
+ return HTML.ul(*[
155
+ HTML.li(literal(ref(session.query(model).filter(model.id == sid)[0])))
156
+ for sid in sorted(source_ids)])
157
+ return link_entity(
158
+ req,
159
+ ml.objid,
160
+ settings_['model_map'][table]["route"],
161
+ settings_['model_map'][table]["model"],
162
+ session or DBSession,
163
+ decorate=decorate,
164
+ **kw,
165
+ )
166
+ log.error("Can't handle [%s] (%s).", ml.objid, table)
167
+ return f"{table}:{ml.objid}"
168
+
169
+
130
170
  def markdown(req, s: str, session=None) -> str:
131
- """
132
- :param req:
133
- :param s:
134
- :param permalink:
135
- :param session:
136
- :return: `str` containing HTML formatting.
137
- """
171
+ """:return: `str` containing HTML formatting."""
138
172
  if __name__ not in req.registry.settings: # pragma: no cover
139
173
  raise KeyError(
140
174
  f'{__name__} must be included in the app config to use the "markdown" function.')
@@ -142,43 +176,9 @@ def markdown(req, s: str, session=None) -> str:
142
176
  source_ids = set()
143
177
 
144
178
  def repl(ml):
145
- def ref(src): # pragma: no cover
146
- if WITH_MARKDOWN:
147
- return base_markdown(src.bibtex().text(markdown=True))
148
- return src.bibtex().text()
149
-
150
179
  if ml.is_cldf_link:
151
180
  try:
152
- table = ml.table_or_fname
153
- if table in settings_['renderer_map'] and "as_link" not in ml.parsed_url_query:
154
- return settings_['renderer_map'][table](
155
- req, ml.objid, table, session or DBSession, **ml.parsed_url_query)
156
- if table in settings_['model_map']:
157
- decorate = settings_['model_map'][table].get("decorate", None)
158
- kw = dict(ml.parsed_url_query.items())
159
- if ml.label and settings_['keep_link_labels']:
160
- kw.setdefault('label', [ml.label])
161
- if table == 'Source':
162
- if ml.objid != '__all__':
163
- source_ids.add(ml.objid)
164
- elif 'cited_only' in ml.parsed_url.query:
165
- model = settings_['model_map'][table]["model"]
166
- return HTML.ul(*[
167
- HTML.li(literal(ref(
168
- (session or DBSession).query(model).filter(model.id == sid)[0]
169
- )))
170
- for sid in sorted(source_ids)])
171
- return link_entity(
172
- req,
173
- ml.objid,
174
- settings_['model_map'][table]["route"],
175
- settings_['model_map'][table]["model"],
176
- session or DBSession,
177
- decorate=decorate,
178
- **kw,
179
- )
180
- log.error("Can't handle [%s] (%s).", ml.objid, table)
181
- return f"{table}:{ml.objid}"
181
+ return _repl(ml, settings_, req, session or DBSession, source_ids)
182
182
  except: # noqa: E722 # pylint: disable=W0702
183
183
  return ml.label
184
184
  return ml
@@ -1,39 +1,40 @@
1
- Metadata-Version: 2.1
2
- Name: clld_markdown_plugin
3
- Version: 1.0.0
4
- Summary: Render CLDF markdown in clld apps.
5
- Home-page: https://github.com/clld/clld-markdown-plugin
6
- Author: Robert Forkel, Florian Matter
7
- Author-email: robert_forkel@eva.mpg.de, florianmatter@gmail.com
8
- Project-URL: Bug Tracker, https://github.com/clld/clld-markdown-plugin/issues
1
+ Metadata-Version: 2.4
2
+ Name: clld-markdown-plugin
3
+ Version: 1.1.0
4
+ Summary: A clld plugin to render CLDF markdown in clld apps.
5
+ Author-email: Robert Forkel <dlce.rdm@eva.mpg.de>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/clld/clld-markdown-plugin
8
+ Keywords: web,pyramid,clld
9
9
  Classifier: Development Status :: 5 - Production/Stable
10
- Classifier: Intended Audience :: Science/Research
11
- Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Intended Audience :: Developers
12
11
  Classifier: Natural Language :: English
12
+ Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
14
  Classifier: Programming Language :: Python :: 3.11
17
15
  Classifier: Programming Language :: Python :: 3.12
18
16
  Classifier: Programming Language :: Python :: 3.13
19
17
  Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
+ Requires-Python: >=3.11
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
- Requires-Dist: frontmatter<1.2; python_version < "3.10"
22
+ Requires-Dist: clld>=7.0
23
23
  Requires-Dist: clldutils
24
24
  Requires-Dist: pycldf
25
- Requires-Dist: clld
26
25
  Requires-Dist: markdown
27
26
  Provides-Extra: dev
28
- Requires-Dist: flake8; extra == "dev"
29
- Requires-Dist: twine; extra == "dev"
27
+ Requires-Dist: ruff; extra == "dev"
30
28
  Requires-Dist: wheel; extra == "dev"
31
29
  Requires-Dist: build; extra == "dev"
30
+ Requires-Dist: twine; extra == "dev"
32
31
  Provides-Extra: test
33
- Requires-Dist: pytest; extra == "test"
32
+ Requires-Dist: pytest>=5; extra == "test"
34
33
  Requires-Dist: pytest-mock; extra == "test"
35
34
  Requires-Dist: pytest-cov; extra == "test"
36
- Requires-Dist: tox; extra == "test"
35
+ Requires-Dist: coverage>=4.2; extra == "test"
36
+ Requires-Dist: webtest; extra == "test"
37
+ Dynamic: license-file
37
38
 
38
39
  # clld-markdown-plugin
39
40
 
@@ -1,8 +1,6 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
- setup.cfg
5
- setup.py
6
4
  src/clld_markdown_plugin/__init__.py
7
5
  src/clld_markdown_plugin.egg-info/PKG-INFO
8
6
  src/clld_markdown_plugin.egg-info/SOURCES.txt
@@ -1,19 +1,17 @@
1
+ clld>=7.0
1
2
  clldutils
2
3
  pycldf
3
- clld
4
4
  markdown
5
5
 
6
- [:python_version < "3.10"]
7
- frontmatter<1.2
8
-
9
6
  [dev]
10
- flake8
11
- twine
7
+ ruff
12
8
  wheel
13
9
  build
10
+ twine
14
11
 
15
12
  [test]
16
- pytest
13
+ pytest>=5
17
14
  pytest-mock
18
15
  pytest-cov
19
- tox
16
+ coverage>=4.2
17
+ webtest
@@ -1,4 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
@@ -1,83 +0,0 @@
1
- [metadata]
2
- version = 1.0.0
3
- author = Robert Forkel, Florian Matter
4
- author_email = robert_forkel@eva.mpg.de, florianmatter@gmail.com
5
- classifiers =
6
- Development Status :: 5 - Production/Stable
7
- Intended Audience :: Science/Research
8
- License :: OSI Approved :: Apache Software License
9
- Natural Language :: English
10
- Programming Language :: Python :: 3
11
- Programming Language :: Python :: 3.9
12
- Programming Language :: Python :: 3.10
13
- Programming Language :: Python :: 3.11
14
- Programming Language :: Python :: 3.12
15
- Programming Language :: Python :: 3.13
16
- Programming Language :: Python :: 3.14
17
- description = Render CLDF markdown in clld apps.
18
- long_description = file: README.md
19
- long_description_content_type = text/markdown
20
- name = clld_markdown_plugin
21
- project_urls =
22
- Bug Tracker = https://github.com/clld/clld-markdown-plugin/issues
23
- url = https://github.com/clld/clld-markdown-plugin
24
-
25
- [options]
26
- zip_safe = False
27
- include_package_data = True
28
- packages = find:
29
- package_dir =
30
- =src
31
- install_requires =
32
- frontmatter<1.2;python_version<"3.10"
33
- clldutils
34
- pycldf
35
- clld
36
- markdown
37
-
38
- [options.extras_require]
39
- dev =
40
- flake8
41
- twine
42
- wheel
43
- build
44
- test =
45
- pytest
46
- pytest-mock
47
- pytest-cov
48
- tox
49
-
50
- [options.packages.find]
51
- include = clld_markdown_plugin, clld_markdown_plugin.*
52
- where = src
53
-
54
- [flake8]
55
- max-line-length = 100
56
- extend-ignore = E203
57
-
58
- [tool:pytest]
59
- addopts = --cov
60
- testpaths = tests
61
- filterwarnings =
62
- ignore::sqlalchemy.exc.RemovedIn20Warning
63
-
64
- [coverage:run]
65
- source =
66
- clld_markdown_plugin
67
-
68
- [coverage:report]
69
- show_missing = true
70
-
71
- [tox:tox]
72
- envlist = py39, py310, py311, py312, py313, py314
73
- isolated_build = true
74
- skip_missing_interpreter = true
75
-
76
- [testenv]
77
- deps = .[test]
78
- commands = pytest {posargs}
79
-
80
- [egg_info]
81
- tag_build =
82
- tag_date = 0
83
-
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- import setuptools
4
-
5
- if __name__ == "__main__":
6
- setuptools.setup()