Skip to content

Commit

Permalink
Embedded jinja2 template code in railroad code to remove use of depre…
Browse files Browse the repository at this point in the history
…cated pkg_resources package (issue #391)
  • Loading branch information
ptmcg committed Apr 30, 2022
1 parent 0d633b6 commit f655b95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
33 changes: 30 additions & 3 deletions pyparsing/diagram/__init__.py
@@ -1,6 +1,5 @@
import railroad
import pyparsing
from pkg_resources import resource_filename
import typing
from typing import (
List,
Expand All @@ -17,8 +16,36 @@
import inspect


with open(resource_filename(__name__, "template.jinja2"), encoding="utf-8") as fp:
template = Template(fp.read())
jinja2_template_source = """\
<!DOCTYPE html>
<html>
<head>
{% if not head %}
<style type="text/css">
.railroad-heading {
font-family: monospace;
}
</style>
{% else %}
{{ head | safe }}
{% endif %}
</head>
<body>
{{ body | safe }}
{% for diagram in diagrams %}
<div class="railroad-group">
<h1 class="railroad-heading">{{ diagram.title }}</h1>
<div class="railroad-description">{{ diagram.text }}</div>
<div class="railroad-svg">
{{ diagram.svg }}
</div>
</div>
{% endfor %}
</body>
</html>
"""

template = Template(jinja2_template_source)

# Note: ideally this would be a dataclass, but we're supporting Python 3.5+ so we can't do this yet
NamedDiagram = NamedTuple(
Expand Down
26 changes: 0 additions & 26 deletions pyparsing/diagram/template.jinja2

This file was deleted.

0 comments on commit f655b95

Please sign in to comment.