Coverage for python / lsst / obs / base / cli / doc / butlerCmdDocGen.py: 0%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-14 23:50 +0000

1# This file is part of obs_base. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21 

22"""Accessor for sphinx documentation generator that accesses the butler 

23subcommand plugins that are provided by this package. 

24""" 

25 

26from __future__ import annotations 

27 

28from typing import cast 

29 

30import click 

31 

32from lsst.utils import doImportType 

33 

34from .. import cmd 

35 

36 

37class ButlerCmdDocGen(click.Group): 

38 """Provide access of butler subcommand plugins to Sphinx.""" 

39 

40 def list_commands(self, ctx: click.Context) -> list[str]: 

41 """List the click commands provided by this package. 

42 

43 Parameters 

44 ---------- 

45 ctx : click.Context 

46 The current Click context. 

47 

48 Returns 

49 ------- 

50 commands : `list` [`str`] 

51 The names of the commands that can be called by the butler command. 

52 """ 

53 return cmd.__all__ 

54 

55 def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None: 

56 """Get a click command provided by this package. 

57 

58 Parameters 

59 ---------- 

60 ctx : `click.Context` 

61 The current Click context. 

62 cmd_name : `str` 

63 The name of the command to return. 

64 

65 Returns 

66 ------- 

67 command : `click.Command` 

68 A Command that wraps a callable command function. 

69 """ 

70 return cast(click.Command | None, doImportType("lsst.obs.base.cli.cmd." + cmd_name)) 

71 

72 

73@click.command(cls=ButlerCmdDocGen) 

74def cli() -> None: 

75 """Run the command.""" 

76 pass