shellman
¤
shellman package.
Write documentation in comments and render it with templates. 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/. Write documentation in comments and render it with templates.
Modules:
-
cli–Deprecated. Import directly from
shellmaninstead. -
context–Deprecated. Import directly from
shellmaninstead. -
reader–Deprecated. Import directly from
shellmaninstead. -
tags–Deprecated. Import directly from
shellmaninstead. -
templates–Deprecated. Import directly from
shellmaninstead.
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())
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
¤
Regex to match a tag without a value.
tag_value_regex
module-attribute
¤
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–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
BriefTag
dataclass
¤
BriefTag(text: str)
Bases: TextTag
A tag representing a summary.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
BugTag
dataclass
¤
BugTag(text: str)
Bases: TextTag
A tag representing a bug note.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
CaveatTag
dataclass
¤
CaveatTag(text: str)
Bases: TextTag
A tag representing caveats.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
CopyrightTag
dataclass
¤
CopyrightTag(text: str)
Bases: TextTag
A tag representing copyright information.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
DateTag
dataclass
¤
DateTag(text: str)
Bases: TextTag
A tag representing a date.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
DescTag
dataclass
¤
DescTag(text: str)
Bases: TextTag
A tag representing a description.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
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
113 114 115 116 117 118 119 120 | |
DocFile
¤
A shell script or documentation file.
Parameters:
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
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
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.
-
shellman-
AuthorTagfrom_lines -
BriefTagfrom_lines -
BugTagfrom_lines -
CaveatTagfrom_lines -
CopyrightTagfrom_lines -
DateTagfrom_lines -
DescTagfrom_lines -
DocBlockappend -
EnvTagfrom_lines -
ErrorTagfrom_lines -
ExampleTagfrom_lines -
ExitTagfrom_lines -
FileTagfrom_lines -
FunctionTagfrom_lines -
HistoryTagfrom_lines -
LicenseTagfrom_lines -
NoteTagfrom_lines -
OptionTagfrom_lines -
SeealsoTagfrom_lines -
StderrTagfrom_lines -
StdinTagfrom_lines -
StdoutTagfrom_lines -
Tagfrom_lines -
TextTagfrom_lines -
UsageTagfrom_lines -
ValueDescTagfrom_lines -
VersionTagfrom_lines
-
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
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
DocStream
¤
A stream of shell code or documentation.
Parameters:
Attributes:
Source code in src/shellman/_internal/reader.py
183 184 185 186 187 188 189 190 191 192 193 194 195 | |
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 value and its description from documentation lines.
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 used to identify environment variables.
-
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 value and its description from documentation lines.
Parameters:
Returns:
-
Self–A tag instance with the value and description stored in the configured fields.
Source code in src/shellman/_internal/tags.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
ErrorTag
dataclass
¤
ErrorTag(text: str)
Bases: TextTag
A tag representing a known error.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
ExampleTag
dataclass
¤
Bases: Tag
A tag representing a code/shell example.
Methods:
-
from_lines–Parse an example's summary, code, language, and description.
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 an example's summary, code, language, and description.
Parameters:
Returns:
-
ExampleTag–An example tag with the parsed sections.
Source code in src/shellman/_internal/tags.py
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 | |
ExitTag
dataclass
¤
Bases: ValueDescTag
A tag representing an exit code.
Methods:
-
from_lines–Parse a value and its description from documentation lines.
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 used to identify exit codes.
-
value_field_name(str) –The name of the field containing the exit code.
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 exit code.
from_lines
classmethod
¤
Parse a value and its description from documentation lines.
Parameters:
Returns:
-
Self–A tag instance with the value and description stored in the configured fields.
Source code in src/shellman/_internal/tags.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
FileTag
dataclass
¤
Bases: ValueDescTag
A tag representing a file used by a script.
Methods:
-
from_lines–Parse a value and its description from documentation lines.
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 used to identify files.
-
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 value and its description from documentation lines.
Parameters:
Returns:
-
Self–A tag instance with the value and description stored in the configured fields.
Source code in src/shellman/_internal/tags.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
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 shell function's prototype and documentation sections.
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 shell function's prototype and documentation sections.
Parameters:
Returns:
-
FunctionTag–A function tag with the parsed prototype and documentation.
Source code in src/shellman/_internal/tags.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
HistoryTag
dataclass
¤
HistoryTag(text: str)
Bases: TextTag
A tag representing a script's history.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
LicenseTag
dataclass
¤
LicenseTag(text: str)
Bases: TextTag
A tag representing a license.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
NoteTag
dataclass
¤
NoteTag(text: str)
Bases: TextTag
A tag representing a note.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
OptionTag
dataclass
¤
Bases: Tag
A tag representing a command-line option.
Methods:
-
from_lines–Parse an option's flags, arguments, default value, group, and description.
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 an option's flags, arguments, default value, group, and description.
Parameters:
Returns:
-
OptionTag–An option tag with the parsed signature and supporting information.
Source code in src/shellman/_internal/tags.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
SeealsoTag
dataclass
¤
SeealsoTag(text: str)
Bases: TextTag
A tag representing "See Also" information.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
StderrTag
dataclass
¤
StderrTag(text: str)
Bases: TextTag
A tag representing the standard error of a script/function.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
StdinTag
dataclass
¤
StdinTag(text: str)
Bases: TextTag
A tag representing the standard input of a script/function.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
StdoutTag
dataclass
¤
StdoutTag(text: str)
Bases: TextTag
A tag representing the standard output of a script/function.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
Tag
¤
Base class for tags.
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
46 47 48 49 50 51 52 53 54 55 56 | |
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
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 | |
render
¤
Render the template.
Parameters:
Returns:
-
str–The rendered text.
Source code in src/shellman/_internal/templates/__init__.py
99 100 101 102 103 104 105 106 107 108 109 110 111 | |
TextTag
dataclass
¤
TextTag(text: str)
Bases: Tag
A simple tag holding text only.
-
shellman-
AuthorTagfrom_lines -
BriefTagfrom_lines -
BugTagfrom_lines -
CaveatTagfrom_lines -
CopyrightTagfrom_lines -
DateTagfrom_lines -
DescTagfrom_lines -
ErrorTagfrom_lines -
HistoryTagfrom_lines -
LicenseTagfrom_lines -
NoteTagfrom_lines -
SeealsoTagfrom_lines -
StderrTagfrom_lines -
StdinTagfrom_lines -
StdoutTagfrom_lines -
TextTagfrom_lines -
VersionTagfrom_lines
-
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
UsageTag
dataclass
¤
Bases: Tag
A tag representing the command-line usage of a script.
Methods:
-
from_lines–Parse a program name and its command-line usage.
Attributes:
from_lines
classmethod
¤
Parse a program name and its command-line usage.
Parameters:
-
(lines¤Sequence[DocLine]) –A non-empty sequence of documentation lines starting with the program name.
Returns:
-
UsageTag–A usage tag with the program name and the remaining text as its command.
Source code in src/shellman/_internal/tags.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | |
ValueDescTag
dataclass
¤
ValueDescTag()
Bases: Tag
A tag holding a value and a description.
Methods:
-
from_lines–Parse a value and its description from documentation lines.
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 value and its description from documentation lines.
Parameters:
Returns:
-
Self–A tag instance with the value and description stored in the configured fields.
Source code in src/shellman/_internal/tags.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
VersionTag
dataclass
¤
VersionTag(text: str)
Bases: TextTag
A tag representing a version.
Methods:
-
from_lines–Join documentation line values into a text tag.
Attributes:
from_lines
classmethod
¤
Join documentation line values into a text tag.
Parameters:
Returns:
-
TextTag–A tag instance with line values joined by newline characters.
Source code in src/shellman/_internal/tags.py
66 67 68 69 70 71 72 73 74 75 76 | |
console_width
¤
Return current console width.
Parameters:
Returns:
-
int–The console width.
Source code in src/shellman/_internal/templates/filters.py
164 165 166 167 168 169 170 171 172 173 174 175 | |
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
132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
do_escape
¤
do_escape(
value: str, except_starts_with: list[str] | None = None
) -> str
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
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
do_firstline
¤
do_firstline(
string_or_list: str | Sequence[str],
) -> str | None
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
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
do_firstword
¤
do_firstword(string: str, delimiters: str = ' ') -> str
Get the first word of a string.
Parameters:
Returns:
-
str–The string's first word.
Source code in src/shellman/_internal/templates/filters.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
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
243 244 245 246 247 248 249 250 251 252 253 254 | |
do_groffauto
¤
Convert a string to the Groff format.
Parameters:
-
(string¤str) –The string to convert.
-
(escape¤bool, default:True) –Whether to escape the result.
Returns:
-
str–A Groff string.
Source code in src/shellman/_internal/templates/filters.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
do_groffautoemphasis
¤
Automatically mark uppercase words as Groff emphasis.
Parameters:
Returns:
-
str–The updated string.
Source code in src/shellman/_internal/templates/filters.py
75 76 77 78 79 80 81 82 83 84 | |
do_groffautoescape
¤
Automatically Groff-escape dashes, single/double quotes, dots and dollar signs in a string.
Parameters:
Returns:
-
str–The escaped string.
Source code in src/shellman/_internal/templates/filters.py
39 40 41 42 43 44 45 46 47 48 | |
do_groffautostrong
¤
Automatically mark words starting with - or -- as Groff strong.
Parameters:
Returns:
-
str–The updated string.
Source code in src/shellman/_internal/templates/filters.py
87 88 89 90 91 92 93 94 95 96 | |
do_groffemphasis
¤
Mark a string as Groff emphasis.
Parameters:
Returns:
-
str–The updated string.
Source code in src/shellman/_internal/templates/filters.py
63 64 65 66 67 68 69 70 71 72 | |
do_groffstrong
¤
Mark a string as Groff strong.
Parameters:
Returns:
-
str–The updated string.
Source code in src/shellman/_internal/templates/filters.py
51 52 53 54 55 56 57 58 59 60 | |
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
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 | |
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
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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
get_parser
¤
get_parser() -> ArgumentParser
Return the CLI argument parser.
Returns:
-
ArgumentParser–An argparse parser.
Source code in src/shellman/_internal/cli.py
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
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
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 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
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.