
Generate ROFF man pages programmatically using an abstract document model, inline styles, control directives, text-formatting helpers, and safe rendering with apostrophe handling.
A Kotlin Multiplatform Native library for generating documents in the ROFF format (man pages). This is a port of the Rust roff-rs library.
ROFF is a family of Unix text-formatting languages,
implemented by the nroff, troff, and groff programs. This library provides an abstract
representation of ROFF documents, making it easy to generate manual pages programmatically.
This library is not yet published to Maven Central. The recommended approach is to include it as a git submodule or vendored dependency:
git submodule add https://github.com/KotlinMania/roff-kotlin.gitThen in your settings.gradle.kts:
include(":roff-kotlin")And in your module's build.gradle.kts:
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":roff-kotlin"))
}
}
}
}import roff.*
val page = Roff()
.control("TH", "CORRUPT", "1")
.control("SH", "NAME")
.text(roman("corrupt - modify files by randomly changing bits"))
.control("SH", "SYNOPSIS")
.text(
bold("corrupt"), " [".toInline(), bold("-n"), " ".toInline(),
italic("BITS"), "] [".toInline(), bold("--bits"), " ".toInline(),
italic("BITS"), "] ".toInline(), italic("FILE"), "...".toInline()
)
.control("SH", "DESCRIPTION")
.text(bold("corrupt"), " modifies files by toggling a randomly chosen bit.".toInline())
.control("SH", "OPTIONS")
.control("TP")
.text(bold("-n"), ", ".toInline(), bold("--bits"), "=".toInline(), italic("BITS"))
.text(roman("Set the number of bits to modify. Default is one bit."))
.render()
print(page)val doc = Roff()
.control("TH", "NAME", "SECTION") // Control line with arguments
.text(roman("Plain text")) // Text line
.render() // Render with apostrophe handlingroman("text") - Normal (roman) fontbold("text") - Bold fontitalic("text") - Italic fontlineBreak() - Hard line break"text".toInline() - Convert string to roman inlinerender() - Render with apostrophe preamble (recommended for man pages)toRoff() - Render without apostrophe handling (for testing)Licensed under either of:
at your option.
This Kotlin Multiplatform port was created by Sydney Renee of The Solace Project for KotlinMania.
Special thanks to the original authors:
A Kotlin Multiplatform Native library for generating documents in the ROFF format (man pages). This is a port of the Rust roff-rs library.
ROFF is a family of Unix text-formatting languages,
implemented by the nroff, troff, and groff programs. This library provides an abstract
representation of ROFF documents, making it easy to generate manual pages programmatically.
This library is not yet published to Maven Central. The recommended approach is to include it as a git submodule or vendored dependency:
git submodule add https://github.com/KotlinMania/roff-kotlin.gitThen in your settings.gradle.kts:
include(":roff-kotlin")And in your module's build.gradle.kts:
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":roff-kotlin"))
}
}
}
}import roff.*
val page = Roff()
.control("TH", "CORRUPT", "1")
.control("SH", "NAME")
.text(roman("corrupt - modify files by randomly changing bits"))
.control("SH", "SYNOPSIS")
.text(
bold("corrupt"), " [".toInline(), bold("-n"), " ".toInline(),
italic("BITS"), "] [".toInline(), bold("--bits"), " ".toInline(),
italic("BITS"), "] ".toInline(), italic("FILE"), "...".toInline()
)
.control("SH", "DESCRIPTION")
.text(bold("corrupt"), " modifies files by toggling a randomly chosen bit.".toInline())
.control("SH", "OPTIONS")
.control("TP")
.text(bold("-n"), ", ".toInline(), bold("--bits"), "=".toInline(), italic("BITS"))
.text(roman("Set the number of bits to modify. Default is one bit."))
.render()
print(page)val doc = Roff()
.control("TH", "NAME", "SECTION") // Control line with arguments
.text(roman("Plain text")) // Text line
.render() // Render with apostrophe handlingroman("text") - Normal (roman) fontbold("text") - Bold fontitalic("text") - Italic fontlineBreak() - Hard line break"text".toInline() - Convert string to roman inlinerender() - Render with apostrophe preamble (recommended for man pages)toRoff() - Render without apostrophe handling (for testing)Licensed under either of:
at your option.
This Kotlin Multiplatform port was created by Sydney Renee of The Solace Project for KotlinMania.
Special thanks to the original authors: