shellman ¤
shellman package.
Read documentation from shell script comments and render it with templates.
shellman reads specified FILEs and searches for special comments beginning with two sharps (##). It extracts documentation from these comment lines, and then generate a document by rendering a template. The template rendering is done with Jinja2. See https://jinja.palletsprojects.com/en/3.1.x/.
Modules:
-
cli
–Deprecated. Import directly from
shellman
instead. -
context
–Deprecated. Import directly from
shellman
instead. -
reader
–Deprecated. Import directly from
shellman
instead. -
tags
–Deprecated. Import directly from
shellman
instead. -
templates
–Deprecated. Import directly from
shellman
instead.
Classes:
-
AuthorTag
–A tag representing an author.
-
BriefTag
–A tag representing a summary.
-
BugTag
–A tag representing a bug note.
-
CaveatTag
–A tag representing caveats.
-
CopyrightTag
–A tag representing copyright information.
-
DateTag
–A tag representing a date.
-
DescTag
–A tag representing a description.
-
DocBlock
–A documentation block.
-
DocFile
–A shell script or documentation file.
-
DocLine
–A documentation line.
-
DocStream
–A stream of shell code or documentation.
-
DocType
–Enumeration of the possible types of documentation.
-
EnvTag
–A tag representing an environment variable used by the script.
-
ErrorTag
–A tag representing a known error.
-
ExampleTag
–A tag representing a code/shell example.
-
ExitTag
–A tag representing an exit code.
-
FileTag
–A tag representing a file used by a script.
-
FunctionTag
–A tag representing a shell function.
-
HistoryTag
–A tag representing a script's history.
-
LicenseTag
–A tag representing a license.
-
NoteTag
–A tag representing a note.
-
OptionTag
–A tag representing a command-line option.
-
SeealsoTag
–A tag representing "See Also" information.
-
StderrTag
–A tag representing the standard error of a script/function.
-
StdinTag
–A tag representing the standard input of a script/function.
-
StdoutTag
–A tag representing the standard output of a script/function.
-
Tag
–Base class for tags.
-
Template
–Shellman templates.
-
TextTag
–A simple tag holding text only.
-
UsageTag
–A tag representing the command-line usage of a script.
-
ValueDescTag
–A tag holding a value and a description.
-
VersionTag
–A tag representing a version.
Functions:
-
console_width
–Return current console width.
-
do_body
–Get the body of a text.
-
do_escape
–Escape (HTML) given text.
-
do_firstline
–Get the first line of a text.
-
do_firstword
–Get the first word of a string.
-
do_format
–Override Jinja's format filter to use format method instead of % operator.
-
do_groffauto
–Convert a string to the Groff format.
-
do_groffautoemphasis
–Automatically mark uppercase words as Groff emphasis.
-
do_groffautoescape
–Automatically Groff-escape dashes, single/double quotes, dots and dollar signs in a string.
-
do_groffautostrong
–Automatically mark words starting with
-
or--
as Groff strong. -
do_groffemphasis
–Mark a string as Groff emphasis.
-
do_groffstrong
–Mark a string as Groff strong.
-
do_groupby
–Override Jinja's groupby filter to add un(sort) option.
-
do_smartwrap
–Smartly wrap the given text.
-
get_parser
–Return the CLI argument parser.
-
main
–Run the main program.
Attributes:
-
DEFAULT_JSON_FILE
–The default JSON file to read context from.
-
ENV_VAR_PREFIX
–The prefix for environment variables that will be used as context.
-
FILTERS
–The Jinja filters.
-
TAGS
(dict[str | None, type[Tag]]
) –A dictionary of tag names and their corresponding tag classes.
-
builtin_env
–The built-in Jinja environment.
-
helptext
–Template for help text.
-
manpage
–Template for manpages.
-
manpage_md
–Template for manpages in Markdown format.
-
tag_no_value_regex
–Regex to match a tag without a value.
-
tag_value_regex
–Regex to match a tag and its value.
-
usagetext
–Template for usage text.
-
wikipage
–Template for wiki pages.
DEFAULT_JSON_FILE module-attribute
¤
DEFAULT_JSON_FILE = '.shellman.json'
The default JSON file to read context from.
ENV_VAR_PREFIX module-attribute
¤
ENV_VAR_PREFIX = 'SHELLMAN_CONTEXT_'
The prefix for environment variables that will be used as context.
FILTERS module-attribute
¤
FILTERS = {
"groffstrong": do_groffstrong,
"groffemphasis": do_groffemphasis,
"groffautostrong": do_groffautostrong,
"groffautoemphasis": do_groffautoemphasis,
"groffautoescape": do_groffautoescape,
"groffauto": do_groffauto,
"groupby": do_groupby,
"firstword": do_firstword,
"firstline": do_firstline,
"body": do_body,
"smartwrap": do_smartwrap,
"format": do_format,
"escape": do_escape,
}
The Jinja filters.
TAGS module-attribute
¤
TAGS: dict[str | None, type[Tag]] = {
None: TextTag,
"author": AuthorTag,
"bug": BugTag,
"brief": BriefTag,
"caveat": CaveatTag,
"copyright": CopyrightTag,
"date": DateTag,
"desc": DescTag,
"env": EnvTag,
"error": ErrorTag,
"example": ExampleTag,
"exit": ExitTag,
"file": FileTag,
"function": FunctionTag,
"history": HistoryTag,
"license": LicenseTag,
"note": NoteTag,
"option": OptionTag,
"seealso": SeealsoTag,
"stderr": StderrTag,
"stdin": StdinTag,
"stdout": StdoutTag,
"usage": UsageTag,
"version": VersionTag,
}
A dictionary of tag names and their corresponding tag classes.
builtin_env module-attribute
¤
builtin_env = _get_env(_get_builtin_path())
The built-in Jinja environment.
helptext module-attribute
¤
helptext = Template(
builtin_env,
"helptext",
context={"indent": 2, "option_padding": 22},
)
Template for help text.
manpage module-attribute
¤
manpage = Template(
builtin_env, "manpage.groff", context={"indent": 4}
)
Template for manpages.
manpage_md module-attribute
¤
manpage_md = Template(builtin_env, 'manpage.md')
Template for manpages in Markdown format.
tag_no_value_regex module-attribute
¤
tag_no_value_regex = compile(
"^\\s*[\\\\@]([_a-zA-Z][\\w-]*)\\s*$"
)
Regex to match a tag without a value.
tag_value_regex module-attribute
¤
tag_value_regex = compile(
"^\\s*[\\\\@]([_a-zA-Z][\\w-]*)\\s+(.+)$"
)
Regex to match a tag and its value.
usagetext module-attribute
¤
usagetext = Template(builtin_env, 'usagetext')
Template for usage text.
wikipage module-attribute
¤
wikipage = Template(builtin_env, 'wikipage.md')
Template for wiki pages.
AuthorTag dataclass
¤
AuthorTag(text: str)
Bases: TextTag
A tag representing an author.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
BriefTag dataclass
¤
BriefTag(text: str)
Bases: TextTag
A tag representing a summary.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
BugTag dataclass
¤
BugTag(text: str)
Bases: TextTag
A tag representing a bug note.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
CaveatTag dataclass
¤
CaveatTag(text: str)
Bases: TextTag
A tag representing caveats.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
CopyrightTag dataclass
¤
CopyrightTag(text: str)
Bases: TextTag
A tag representing copyright information.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
DateTag dataclass
¤
DateTag(text: str)
Bases: TextTag
A tag representing a date.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
DescTag dataclass
¤
DescTag(text: str)
Bases: TextTag
A tag representing a description.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
DocBlock ¤
A documentation block.
Parameters:
Methods:
Attributes:
-
doc_type
(str
) –The block type.
-
first_line
(DocLine
) –The block's first doc line.
-
lineno
(int
) –The block's first line number.
-
lines
–The block's doc lines.
-
lines_number
(int
) –The number of lines in the block.
-
path
(str
) –The block's origin file path.
-
tag
(str
) –The block's tag.
-
value
(str
) –The block's first line.
-
values
(list[str]
) –The block's lines.
Source code in src/shellman/_internal/reader.py
95 96 97 98 99 100 101 102 |
|
__bool__ ¤
__bool__() -> bool
True if the block has lines.
Source code in src/shellman/_internal/reader.py
104 105 106 |
|
append ¤
append(line: DocLine) -> None
Append a line to the block.
Parameters:
-
line
(DocLine
) –The doc line to append.
Source code in src/shellman/_internal/reader.py
111 112 113 114 115 116 117 |
|
DocFile ¤
DocFile(path: str)
A shell script or documentation file.
Parameters:
-
path
(str
) –The path to the file.
Attributes:
-
filename
–The file name.
-
filepath
–The file path.
-
sections
(dict[str, list[Tag]]
) –The documentation sections.
Source code in src/shellman/_internal/reader.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
DocLine ¤
A documentation line.
Parameters:
-
path
(str
) –The origin file path.
-
lineno
(int
) –The line number in the file.
-
tag
(str | None
) –The line's tag, if any.
-
value
(str
) –The line's value.
Attributes:
-
doc_type
(str
) –The line's doc type.
-
lineno
–The line number in the file.
-
path
–The origin file path.
-
tag
–The line's tag.
-
value
–The line's value.
Source code in src/shellman/_internal/reader.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
DocStream ¤
A stream of shell code or documentation.
Parameters:
Attributes:
Source code in src/shellman/_internal/reader.py
165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
DocType ¤
Enumeration of the possible types of documentation.
Attributes:
EnvTag dataclass
¤
Bases: ValueDescTag
A tag representing an environment variable used by the script.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
-
description
(str
) –The environment variable description.
-
description_field_name
(str
) –The name of the field containing the description.
-
name
(str
) –The environment variable name.
-
tag
(str
) –The tag name.
-
value_field_name
(str
) –The name of the field containing the value.
description_field_name class-attribute
¤
description_field_name: str = 'description'
The name of the field containing the description.
value_field_name class-attribute
¤
value_field_name: str = 'name'
The name of the field containing the value.
from_lines classmethod
¤
Parse a sequence of lines into a tag instance.
Parameters:
Returns:
-
Tag
–A tag instance.
Source code in src/shellman/_internal/tags.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
ErrorTag dataclass
¤
ErrorTag(text: str)
Bases: TextTag
A tag representing a known error.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
ExampleTag dataclass
¤
Bases: Tag
A tag representing a code/shell example.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
-
brief
(str
) –The example's summary.
-
code
(str
) –The example's code.
-
code_lang
(str
) –The example's language.
-
description
(str
) –The example's description.
from_lines classmethod
¤
from_lines(lines: Sequence[DocLine]) -> ExampleTag
Parse a sequence of lines into a tag instance.
Parameters:
Returns:
-
Tag
–A tag instance.
Source code in src/shellman/_internal/tags.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
ExitTag dataclass
¤
Bases: ValueDescTag
A tag representing an exit code.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
-
code
(str
) –The exit code value.
-
description
(str
) –The exit code description.
-
description_field_name
(str
) –The name of the field containing the description.
-
tag
(str
) –The tag name.
-
value_field_name
(str
) –The name of the field containing the value.
description_field_name class-attribute
¤
description_field_name: str = 'description'
The name of the field containing the description.
value_field_name class-attribute
¤
value_field_name: str = 'code'
The name of the field containing the value.
from_lines classmethod
¤
Parse a sequence of lines into a tag instance.
Parameters:
Returns:
-
Tag
–A tag instance.
Source code in src/shellman/_internal/tags.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
FileTag dataclass
¤
Bases: ValueDescTag
A tag representing a file used by a script.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
-
description
(str
) –The file description.
-
description_field_name
(str
) –The name of the field containing the description.
-
name
(str
) –The file name/path.
-
tag
(str
) –The tag name.
-
value_field_name
(str
) –The name of the field containing the value.
description_field_name class-attribute
¤
description_field_name: str = 'description'
The name of the field containing the description.
value_field_name class-attribute
¤
value_field_name: str = 'name'
The name of the field containing the value.
from_lines classmethod
¤
Parse a sequence of lines into a tag instance.
Parameters:
Returns:
-
Tag
–A tag instance.
Source code in src/shellman/_internal/tags.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
FunctionTag dataclass
¤
FunctionTag(
prototype: str,
brief: str,
description: str,
arguments: Sequence[str],
preconditions: Sequence[str],
return_codes: Sequence[str],
seealso: Sequence[str],
stderr: Sequence[str],
stdin: Sequence[str],
stdout: Sequence[str],
)
Bases: Tag
A tag representing a shell function.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
-
arguments
(Sequence[str]
) –The function's arguments.
-
brief
(str
) –The function's summary.
-
description
(str
) –The function's description.
-
preconditions
(Sequence[str]
) –The function's preconditions.
-
prototype
(str
) –The function's prototype.
-
return_codes
(Sequence[str]
) –The function's return codes.
-
seealso
(Sequence[str]
) –The function's "see also" information.
-
stderr
(Sequence[str]
) –The function's standard error.
-
stdin
(Sequence[str]
) –The function's standard input.
-
stdout
(Sequence[str]
) –The function's standard output.
from_lines classmethod
¤
from_lines(lines: Sequence[DocLine]) -> FunctionTag
Parse a sequence of lines into a tag instance.
Parameters:
Returns:
-
Tag
–A tag instance.
Source code in src/shellman/_internal/tags.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
HistoryTag dataclass
¤
HistoryTag(text: str)
Bases: TextTag
A tag representing a script's history.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
LicenseTag dataclass
¤
LicenseTag(text: str)
Bases: TextTag
A tag representing a license.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
NoteTag dataclass
¤
NoteTag(text: str)
Bases: TextTag
A tag representing a note.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
OptionTag dataclass
¤
Bases: Tag
A tag representing a command-line option.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
-
default
(str
) –The option default value.
-
description
(str
) –The option description.
-
group
(str
) –The option group.
-
long
(str
) –The option long flag.
-
positional
(str
) –The option positional arguments.
-
short
(str
) –The option short flag.
-
signature
(str
) –The signature of the option.
from_lines classmethod
¤
Parse a sequence of lines into a tag instance.
Parameters:
Returns:
-
Tag
–A tag instance.
Source code in src/shellman/_internal/tags.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
SeealsoTag dataclass
¤
SeealsoTag(text: str)
Bases: TextTag
A tag representing "See Also" information.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
StderrTag dataclass
¤
StderrTag(text: str)
Bases: TextTag
A tag representing the standard error of a script/function.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
StdinTag dataclass
¤
StdinTag(text: str)
Bases: TextTag
A tag representing the standard input of a script/function.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
StdoutTag dataclass
¤
StdoutTag(text: str)
Bases: TextTag
A tag representing the standard output of a script/function.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
Tag ¤
Base class for tags.
-
shellman
-
AuthorTag
from_lines
-
BriefTag
from_lines
-
BugTag
from_lines
-
CaveatTag
from_lines
-
CopyrightTag
from_lines
-
DateTag
from_lines
-
DescTag
from_lines
-
EnvTag
from_lines
-
ErrorTag
from_lines
-
ExampleTag
from_lines
-
ExitTag
from_lines
-
FileTag
from_lines
-
FunctionTag
from_lines
-
HistoryTag
from_lines
-
LicenseTag
from_lines
-
NoteTag
from_lines
-
OptionTag
from_lines
-
SeealsoTag
from_lines
-
StderrTag
from_lines
-
StdinTag
from_lines
-
StdoutTag
from_lines
-
Tag
from_lines
-
TextTag
from_lines
-
UsageTag
from_lines
-
ValueDescTag
from_lines
-
VersionTag
from_lines
-
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
from_lines classmethod
¤
Parse a sequence of lines into a tag instance.
Parameters:
Returns:
-
Tag
–A tag instance.
Source code in src/shellman/_internal/tags.py
35 36 37 38 39 40 41 42 43 44 45 |
|
Template ¤
Template(
env_or_directory: str | Environment,
base_template: str,
context: dict[str, Any] | None = None,
filters: dict[str, Any] | None = None,
)
Shellman templates.
Parameters:
-
env_or_directory
(str | Environment
) –Jinja environment or directory to load environment from.
-
base_template
(str
) –The template file to use.
-
context
(dict[str, Any] | None
, default:None
) –Base context to render with.
-
filters
(dict[str, Any] | None
, default:None
) –Base filters to add to the environment.
Methods:
-
render
–Render the template.
Attributes:
-
base_template
–The base template file.
-
context
–The base context.
-
env
(Environment
) –The Jinja environment.
-
template
(Template
) –The corresponding Jinja template.
Source code in src/shellman/_internal/templates/__init__.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
render ¤
Render the template.
Parameters:
-
**kwargs
(Any
, default:{}
) –Keyword arguments passed to Jinja's render method.
Returns:
-
str
–The rendered text.
Source code in src/shellman/_internal/templates/__init__.py
87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
TextTag dataclass
¤
TextTag(text: str)
Bases: Tag
A simple tag holding text only.
-
shellman
-
AuthorTag
from_lines
-
BriefTag
from_lines
-
BugTag
from_lines
-
CaveatTag
from_lines
-
CopyrightTag
from_lines
-
DateTag
from_lines
-
DescTag
from_lines
-
ErrorTag
from_lines
-
HistoryTag
from_lines
-
LicenseTag
from_lines
-
NoteTag
from_lines
-
SeealsoTag
from_lines
-
StderrTag
from_lines
-
StdinTag
from_lines
-
StdoutTag
from_lines
-
TextTag
from_lines
-
VersionTag
from_lines
-
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
UsageTag dataclass
¤
Bases: Tag
A tag representing the command-line usage of a script.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
from_lines classmethod
¤
Parse a sequence of lines into a tag instance.
Parameters:
Returns:
-
Tag
–A tag instance.
Source code in src/shellman/_internal/tags.py
396 397 398 399 400 401 402 403 404 405 406 |
|
ValueDescTag dataclass
¤
ValueDescTag()
Bases: Tag
A tag holding a value and a description.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
-
description_field_name
(str
) –The name of the field containing the description.
-
tag
(str
) –The tag name.
-
value_field_name
(str
) –The name of the field containing the value.
description_field_name class-attribute
¤
description_field_name: str = 'description'
The name of the field containing the description.
value_field_name class-attribute
¤
value_field_name: str = 'name'
The name of the field containing the value.
from_lines classmethod
¤
Parse a sequence of lines into a tag instance.
Parameters:
Returns:
-
Tag
–A tag instance.
Source code in src/shellman/_internal/tags.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
VersionTag dataclass
¤
VersionTag(text: str)
Bases: TextTag
A tag representing a version.
Methods:
-
from_lines
–Parse a sequence of lines into a tag instance.
Attributes:
console_width ¤
Return current console width.
Parameters:
-
default
(int
, default:80
) –The default value if width cannot be retrieved.
Returns:
-
int
–The console width.
Source code in src/shellman/_internal/templates/filters.py
150 151 152 153 154 155 156 157 158 159 160 161 |
|
do_body ¤
Get the body of a text.
Parameters:
Returns:
-
str | None
–The text's body.
Source code in src/shellman/_internal/templates/filters.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
do_escape ¤
Escape (HTML) given text.
Parameters:
-
except_starts_with
(list[str] | None
, default:None
) –Each line starting with at least one of the prefixes listed in this parameter will not be escaped.
Returns:
-
str
–The escaped text.
Source code in src/shellman/_internal/templates/filters.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
do_firstline ¤
Get the first line of a text.
Parameters:
Returns:
-
str | None
–The text's first line.
Source code in src/shellman/_internal/templates/filters.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
do_firstword ¤
Get the first word of a string.
Parameters:
Returns:
-
str
–The string's first word.
Source code in src/shellman/_internal/templates/filters.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
do_format ¤
Override Jinja's format filter to use format method instead of % operator.
Parameters:
-
string
(str
) –The string to format.
-
*args
(Any
, default:()
) –Arguments passed to
str.format
. -
**kwargs
(Any
, default:{}
) –Keyword arguments passed to
str.format
.
Returns:
-
str
–The formatted string.
Source code in src/shellman/_internal/templates/filters.py
229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
do_groffauto ¤
Convert a string to the Groff format.
Parameters:
Returns:
-
str
–A Groff string.
Source code in src/shellman/_internal/templates/filters.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
do_groffautoemphasis ¤
Automatically mark uppercase words as Groff emphasis.
Parameters:
-
string
(str
) –The string to convert.
Returns:
-
str
–The updated string.
Source code in src/shellman/_internal/templates/filters.py
57 58 59 60 61 62 63 64 65 66 |
|
do_groffautoescape ¤
Automatically Groff-escape dashes, single/double quotes, dots and dollar signs in a string.
Parameters:
-
string
(str
) –The string to escape.
Returns:
-
str
–The escaped string.
Source code in src/shellman/_internal/templates/filters.py
21 22 23 24 25 26 27 28 29 30 |
|
do_groffautostrong ¤
Automatically mark words starting with -
or --
as Groff strong.
Parameters:
-
string
(str
) –The string to convert.
Returns:
-
str
–The updated string.
Source code in src/shellman/_internal/templates/filters.py
69 70 71 72 73 74 75 76 77 78 |
|
do_groffemphasis ¤
Mark a string as Groff emphasis.
Parameters:
-
string
(str
) –The string to convert
Returns:
-
str
–The updated string.
Source code in src/shellman/_internal/templates/filters.py
45 46 47 48 49 50 51 52 53 54 |
|
do_groffstrong ¤
Mark a string as Groff strong.
Parameters:
-
string
(str
) –The string to convert.
Returns:
-
str
–The updated string.
Source code in src/shellman/_internal/templates/filters.py
33 34 35 36 37 38 39 40 41 42 |
|
do_groupby ¤
do_groupby(
environment: Environment,
value: Sequence[Any],
attribute: str,
*,
sort: bool = True,
) -> list[tuple[str, list[Any]]]
Override Jinja's groupby filter to add un(sort) option.
Parameters:
-
environment
(Environment
) –Passed by Jinja.
-
value
(Sequence[Any]
) –The value to group.
-
attribute
(str
) –The attribute to use for grouping/sorting.
Returns:
Source code in src/shellman/_internal/templates/filters.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
do_smartwrap ¤
do_smartwrap(
text: str,
indent: int = 4,
width: int | None = None,
*,
indentfirst: bool = True,
) -> str
Smartly wrap the given text.
Parameters:
-
text
(str
) –The text to wrap.
-
indent
(int
, default:4
) –The indentation to use (number of spaces).
-
width
(int | None
, default:None
) –The desired text width.
-
indentfirst
(bool
, default:True
) –Whether to indent the first line too.
Returns:
-
str
–The wrapped text.
Source code in src/shellman/_internal/templates/filters.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
get_parser ¤
get_parser() -> ArgumentParser
Return the CLI argument parser.
Returns:
-
ArgumentParser
–An argparse parser.
Source code in src/shellman/_internal/cli.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
main ¤
Run the main program.
This function is executed when you type shellman
or python -m shellman
.
Get the file to parse, construct a Doc object, get file's doc, get the according formatter class, instantiate it with acquired doc and write on specified file (stdout by default).
Parameters:
Returns:
-
int
–An exit code.
Source code in src/shellman/_internal/cli.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
cli ¤
Deprecated. Import directly from shellman
instead.
context ¤
Deprecated. Import directly from shellman
instead.
reader ¤
Deprecated. Import directly from shellman
instead.
tags ¤
Deprecated. Import directly from shellman
instead.