Merge pull request #2120 from YunoHost/readme-generator_better-screenshot-handling
readme-generator: only pick files (no folder) on the root of 'screenshots'
This commit is contained in:
commit
01b683b11f
3 changed files with 12 additions and 10 deletions
|
@ -51,6 +51,16 @@ def generate_READMEs(app_path: Path):
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader(Path(__file__).parent / "templates"))
|
env = Environment(loader=FileSystemLoader(Path(__file__).parent / "templates"))
|
||||||
|
|
||||||
|
screenshots: List[str]
|
||||||
|
screenshots = []
|
||||||
|
if (app_path / "doc" / "screenshots").exists():
|
||||||
|
# only pick files (no folder) on the root of 'screenshots'
|
||||||
|
for entry in os.scandir(os.path.join(app_path, "doc", "screenshots")):
|
||||||
|
if os.DirEntry.is_file(entry):
|
||||||
|
# ignore '.gitkeep' or any file whose name begins with a dot
|
||||||
|
if not entry.name.startswith("."):
|
||||||
|
screenshots.append(os.path.relpath(entry.path, app_path))
|
||||||
|
|
||||||
# parse available README template and generate a list in the form of:
|
# parse available README template and generate a list in the form of:
|
||||||
# > [("en", ""), ("fr", "_fr"), ...]
|
# > [("en", ""), ("fr", "_fr"), ...]
|
||||||
available_langs: List[Tuple[str, str]] = [("en", "")]
|
available_langs: List[Tuple[str, str]] = [("en", "")]
|
||||||
|
@ -81,14 +91,6 @@ def generate_READMEs(app_path: Path):
|
||||||
else:
|
else:
|
||||||
description = None
|
description = None
|
||||||
|
|
||||||
screenshots: List[str]
|
|
||||||
if (app_path / "doc" / "screenshots").exists():
|
|
||||||
screenshots = os.listdir(os.path.join(app_path, "doc", "screenshots"))
|
|
||||||
if ".gitkeep" in screenshots:
|
|
||||||
screenshots.remove(".gitkeep")
|
|
||||||
else:
|
|
||||||
screenshots = []
|
|
||||||
|
|
||||||
disclaimer: Optional[str]
|
disclaimer: Optional[str]
|
||||||
if (app_path / "doc" / f"DISCLAIMER{lang_suffix}.md").exists():
|
if (app_path / "doc" / f"DISCLAIMER{lang_suffix}.md").exists():
|
||||||
disclaimer = (app_path / "doc" / f"DISCLAIMER{lang_suffix}.md").read_text()
|
disclaimer = (app_path / "doc" / f"DISCLAIMER{lang_suffix}.md").read_text()
|
||||||
|
|
|
@ -42,7 +42,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
{% for screenshot in screenshots -%}
|
{% for screenshot in screenshots -%}
|
||||||
![Screenshot of {{manifest.name}}](./doc/screenshots/{{screenshot}})
|
![Screenshot of {{manifest.name}}](./{{screenshot}})
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
|
||||||
## Captures d’écran
|
## Captures d’écran
|
||||||
|
|
||||||
{% for screenshot in screenshots -%}
|
{% for screenshot in screenshots -%}
|
||||||
![Capture d’écran de {{manifest.name}}](./doc/screenshots/{{screenshot}})
|
![Capture d’écran de {{manifest.name}}](./{{screenshot}})
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue