Comments (3)
I was imagining a very simple API: the ability to create a custom section, give it a name, and then give it one or more paragraphs of text. (Basically, this would just create a very thin abstraction over the underlying roff
crate, but would be a bit more focused on the semantics instead of the literal formatting.) Using this API to create the "regex syntax" section from ripgrep's man page would look like this:
Manual::new("ripgrep")
// [snip]
custom("regex syntax")
.paragraph("ripgrep uses Rust’s regex engine by default, which documents its syntax: https://docs.rs/regex/*/regex/#syntax")
.paragraph("ripgrep uses byte-oriented regexes, which has some additional documentation: https://docs.rs/regex/*/regex/bytes/index.html#syntax")
.paragraph("To a first approximation, ripgrep uses Perl-like regexes without look-around or backreferences. This makes them very similar to the "extended" (ERE) regular expressions supported by egrep, but with a few additional features like Unicode character classes.")
.paragraph("If you're using ripgrep with the --pcre2 flag, then please consult https://www.pcre.org or the PCRE2 man pages for documentation on the supported syntax.");
This would render:
REGEX SYNTAX
ripgrep uses Rust’s regex engine by default, which documents its syntax: https://docs.rs/regex/*/regex/#syntax
ripgrep uses byte-oriented regexes, which has some additional documentation: https://docs.rs/regex/*/regex/bytes/index.html#syntax
To a first approximation, ripgrep uses Perl-like regexes without look-around or backreferences. This makes them very similar to the "extended" (ERE) regular
expressions supported by egrep, but with a few additional features like Unicode character classes.
If you’re using ripgrep with the --pcre2 flag, then please consult https://www.pcre.org or the PCRE2 man pages for documentation on the supported syntax.
The advantage of this API is that it would be very simple—both to write and, more importantly, to use. However, one disadvantage is that it would not allow for custom formatting for the custom section (e.g., to have command examples printed in bold). That could be addressed by having a separate API for more advanced formatting, though (or by adding in additional sections for the sections that need more detailed formatting, such as an examples sections).
from man.
@codesections I agree having custom sections would be grand! Do you have an idea of what the API would look like that you could share?
from man.
@codesections ohh, yeah I can get behind that design!
However, one disadvantage is that it would not allow for custom formatting for the custom section (e.g., to have command examples printed in bold)
Perhaps we could re-export the roff
crate so people can roll their own if they want to?
from man.
Related Issues (17)
- Which sections should a man page have? HOT 3
- Have method for file path HOT 3
- Have "source" section
- Add DESCRIPTION section
- API design HOT 2
- The README example does not compile HOT 1
- Improve `exit status` section HOT 5
- Add version/date API HOT 1
- Add examples API HOT 1
- Format example in README to show bold HOT 1
- Document full use-case (e.g., `build.rs` script) HOT 5
- Options with no "="
- update to roff 0.2? HOT 1
- Accept more types of positional arguments
- Design: how should we display subcommands? HOT 1
- Move clap v3 -> man glue code to clap_generate HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from man.