]> git.openstreetmap.org Git - nominatim.git/blob - docs/mk_install_instructions.py
import requests library later than osmium
[nominatim.git] / docs / mk_install_instructions.py
1 # SPDX-License-Identifier: GPL-3.0-or-later
2 #
3 # This file is part of Nominatim. (https://nominatim.org)
4 #
5 # Copyright (C) 2024 by the Nominatim developer community.
6 from pathlib import Path
7
8 import mkdocs_gen_files
9
10 VAGRANT_PATH = Path(__file__, '..', '..', 'vagrant').resolve()
11
12 for infile in VAGRANT_PATH.glob('Install-on-*.sh'):
13     outfile = f"admin/{infile.stem}.md"
14     title = infile.stem.replace('-', ' ')
15
16     with mkdocs_gen_files.open(outfile, "w") as outfd, infile.open() as infd:
17         print("#", title, file=outfd)
18         has_empty = False
19         for line in infd:
20             line = line.rstrip()
21             docpos = line.find('#DOCS:')
22             if docpos >= 0:
23                 line = line[docpos + 6:]
24             elif line == '#' or line.startswith('#!'):
25                 line = ''
26             elif line.startswith('# '):
27                 line = line[2:]
28             if line or not has_empty:
29                 print(line, file=outfd)
30                 has_empty = not bool(line)
31
32     mkdocs_gen_files.set_edit_path(outfile, "docs/mk_install_instructions.py")