Skip to content

Commit 78216c8

Browse files
committed
Insert screenshots of themes on the right side
1 parent 372360d commit 78216c8

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

src/best_of/generators/markdown_list.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from best_of import default_config, integrations, utils
1212
from best_of.generators.base_generator import BaseGenerator
13-
from best_of.integrations import github_integration
13+
from best_of.integrations import github_integration, mkdocs_integration
1414
from best_of.license import get_license
1515

1616
log = logging.getLogger(__name__)
@@ -224,18 +224,19 @@ def generate_project_body(project: Dict, configuration: Dict, labels: list) -> s
224224
body_md = "\n\n" + body_md
225225
return body_md
226226

227+
mkdocs_prefix, mkdocs_body = mkdocs_integration.MkDocsIntegration.generate_md_details(project, configuration)
228+
body_md += mkdocs_prefix
229+
227230
if project.github_id:
228231
body_md += github_integration.generate_github_details(project, configuration)
229232

230233
for package_manager in integrations.AVAILABLE_PACKAGE_MANAGER:
231234
package_manager_id = package_manager.name.lower().strip() + "_id"
232-
if (
233-
package_manager_id in project
234-
and project[package_manager_id]
235-
or package_manager.name == "mkdocs"
236-
):
235+
if package_manager_id in project and project[package_manager_id]:
237236
body_md += package_manager.generate_md_details(project, configuration)
238237

238+
body_md += mkdocs_body
239+
239240
if not body_md:
240241
# show message if no information is available
241242
body_md = "- _No project information available._"

src/best_of/integrations/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
gitlab_integration,
99
go_integration,
1010
maven_integration,
11-
mkdocs_integration,
1211
npm_integration,
1312
pypi_integration,
1413
)
@@ -24,7 +23,6 @@
2423
dockerhub_integration.DockerhubIntegration(),
2524
cargo_integration.CargoIntegration(),
2625
go_integration.GoIntegration(),
27-
mkdocs_integration.MkDocsIntegration(),
2826
]
2927

3028
# TODO: "helm_id", "brew_id", "apt_id", "yum_id", "snap_id", "dnf_id", "yay_id",

src/best_of/integrations/mkdocs_integration.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from addict import Dict
22

3-
from best_of.integrations.base_integration import BaseIntegration
4-
53

64
def _get_as_list(mapping, key):
75
names = mapping.get(key, ())
@@ -10,17 +8,11 @@ def _get_as_list(mapping, key):
108
return names
119

1210

13-
class MkDocsIntegration(BaseIntegration):
14-
@property
15-
def name(self) -> str:
16-
return "mkdocs"
17-
18-
def update_project_info(self, project_info: Dict) -> None:
19-
pass
20-
21-
def generate_md_details(self, project: Dict, configuration: Dict) -> str:
11+
class MkDocsIntegration:
12+
@staticmethod
13+
def generate_md_details(project: Dict, configuration: Dict):
2214
if not configuration.generate_install_hints:
23-
return ""
15+
return "", ""
2416

2517
themes = _get_as_list(project, "mkdocs_theme")
2618
plugins = _get_as_list(project, "mkdocs_plugin")
@@ -44,9 +36,18 @@ def generate_md_details(self, project: Dict, configuration: Dict) -> str:
4436
yml += ["markdown_extensions:"] + [f" - {x}" for x in extensions]
4537

4638
if not config_keys:
47-
return ""
39+
return "", ""
4840
url = f"https://www.mkdocs.org/user-guide/configuration/#{config_keys[0]}"
4941

42+
if themes:
43+
prefix = (
44+
f'<a href="https://pawamoy.github.io/mkdocs-gallery/themes/{themes[0]}/">\n'
45+
f'<img src="https://pawamoy.github.io/mkdocs-gallery/assets/img/{themes[0]}.png" width="400" align="right">\n'
46+
f"</a>\n\n"
47+
)
48+
else:
49+
prefix = ""
50+
5051
lines = [
5152
f"Add to [mkdocs.yml]({url}):",
5253
"```yaml",
@@ -60,4 +61,5 @@ def generate_md_details(self, project: Dict, configuration: Dict) -> str:
6061
*yml_extra,
6162
"```",
6263
]
63-
return "- " + "".join(f" {line}\n" for line in lines).lstrip()
64+
body = "- " + "".join(f" {line}\n" for line in lines).lstrip()
65+
return prefix, body

0 commit comments

Comments
 (0)