Debian Codegraph @

ansible_collections/community/routeros/noxfile.py

raw
1 # Copyright (c) Ansible Project
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 # The following metadata allows Python runners and nox to install the required
6 # dependencies for running this Python script:
7 #
8 # /// script
9 # dependencies = ["nox>=2025.02.09", "antsibull-nox"]
10 # ///
11
12 import os
13 import sys
14
15 import nox
16
17
18 # We try to import antsibull-nox, and if that doesn't work, provide a more useful
19 # error message to the user.
20 try:
21 import antsibull_nox
22 except ImportError:
23 print("You need to install antsibull-nox in the same Python environment as nox.")
24 sys.exit(1)
25
26
27 IN_CI = os.environ.get("CI") == "true"
28
29
30 antsibull_nox.load_antsibull_nox_toml()
31
32
33 @nox.session(name="update-docs", default=True)
34 def update_docs_fragments(session: nox.Session) -> None:
35 """
36 Update/check auto-generated parts of docs fragments.
37 """
38 session.install("ansible-core")
39 prepare = antsibull_nox.sessions.prepare_collections(
40 session, install_in_site_packages=True
41 )
42 if not prepare:
43 return
44 data = ["python", "tests/update-docs.py"]
45 if IN_CI:
46 data.append("--lint")
47 session.run(*data)
48
49
50 # Allow to run the noxfile with `python noxfile.py`, `pipx run noxfile.py`, or similar.
51 # Requires nox >= 2025.02.09
52 if __name__ == "__main__":
53 nox.main()