Giter Club home page Giter Club logo

stdman's Introduction

C++ stdlib man pages

stdman is a tool that parses archived HTML files from cppreference and generates groff-formatted manual pages for Unix-based systems. The goal is to provide excellent formatting for easy readability. stdman has been tested on Linux and OS X.

Sample

Installation

There's no need to compile stdman if you just want to install the man pages. Instead, just run:

./configure
make install # as a user with appropriate permissions to install

If you need to pass options to configure, you can do so. See ./configure --help for more updated information.

Troubleshooting

If you're getting 'no manual entry for std::foo' or you're seeing the libstdc++ man pages (characterized by a huge list of typedefs when you run man std::string), see the following. By default, stdman will install to /usr/local; on some systems, the manpath does not look there first. To fix this, you have two options:

  • Install to /usr/share:
./configure --prefix=/usr # will replace existing libstdc++ pages
make install
  • Manage your MANPATH in your ~/.bashrc (or similar):
export MANPATH=/usr/local/man:/usr/local/share/man:/usr/share/man:/usr/man

If your output is not colorized

You either need to set your pager up to colorize man pages, or you need to install a pager to do this for you. less will not do this by default, but it's easy enough to add. most will do this by default, but it doesn't ship with vim-like navigation.

To configure less:

# Colors
default=$(tput sgr0)
red=$(tput setaf 1)
green=$(tput setaf 2)
purple=$(tput setaf 5)
orange=$(tput setaf 9)

# Less colors for man pages
export PAGER=less
# Begin blinking
export LESS_TERMCAP_mb=$red
# Begin bold
export LESS_TERMCAP_md=$orange
# End mode
export LESS_TERMCAP_me=$default
# End standout-mode
export LESS_TERMCAP_se=$default
# Begin standout-mode - info box
export LESS_TERMCAP_so=$purple
# End underline
export LESS_TERMCAP_ue=$default
# Begin underline
export LESS_TERMCAP_us=$green

To install most:
Arch: pacman -S most
Ubuntu: apt-get install most

export MANPAGER=most # in ~/.bashrc or similar

Building/Generating

Should you want to build the source to make modifications and/or generate your own man pages, simply:

make generate # will build stdman and generate man pages

NOTE: make generate expects sources will be in the ./reference/en/cpp directory by default. See ./configure --help to modify this.

Compilation/Generation Dependencies

  • C++11 (recommended GCC 4.9 or clang 3.4 or greater)
  • elinks (recommended 0.12pre6 or greater)
  • gzip (recommended 1.3.12 or greater)

NOTE: Generation not tested on Windows/cygwin.

stdman's People

Contributors

badshah400 avatar benabik avatar carlocab avatar coxm avatar fmorgner avatar jeaye avatar lorenzhs avatar mohd-akram avatar stek29 avatar theidexisted avatar wilhelmtell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stdman's Issues

Extraneous 'A's in OS X

This is a Unicode issue with non-breaking space, I believe. It would be best to just remove any instances of it (they come in from elinks/html).

`apropos` does not show CPPreference manpages

Thank you very much for providing this converter!

I've found a minor issue here: the command apropos (aka man -k)
uses a "whatis" database built using the command mandb to show a
list of manual pages matching a given keyword (at least on Linux).

The program mandb fails to extract the expected information from the
CPPreference manpages because they do not have a "NAME" section.

The following patch fixes this:

diff --git a/src/groff.hpp b/src/groff.hpp
index 1554a62..db1d41a 100644
--- a/src/groff.hpp
+++ b/src/groff.hpp
@@ -39,7 +39,9 @@ class groff
       /* First two lines are always the same. */
       state.lines[0] = ".TH " + name + " 3 "
                        "\"" + state.creation_date + "\" \"" + state.version + " | http://cppreference.com\" "
-                       "\"C++ Standard Libary\"";
+                       "\"C++ Standard Libary\""
+                       "\n" ".SH NAME\n" +
+                        name + " \\- " + name + "\n" ;
       state.lines[1] = "Synopsis";

       groff_detail::section(state.lines);

Note that I simply use the name of the method as its description. It's very
rough, maybe there is a way to extract a one-line description from the
text.

mandb warnings with some operators

When installing, and running sudo mandb, I get:

mandb: warning: failed to store entry for std::filesystem::directory_entry::operator==,!=,,>=,(3)
mandb: warning: failed to store entry for std::type_index::operator==,!=,,>=,(3)
mandb: warning: failed to store entry for std::chrono::operator==,,>=,(std::chrono::leap_second)(3)
mandb: warning: failed to store entry for std::experimental::filesystem::directory_entry::operator==,!=,,>=(3)

The corresponding documentation is for, e.g.:
image

It seems that operators < and > are somehow missing in the warning text ==,!=,,>=,, which perhaps explains the problem.

Colorized output

I expected it to be in color, like in your preview )
A short instruction or a link in the README how to make output colorized would be helpful.

For Ubuntu:

sudo apt-get install most
echo 'export MANPAGER="most"' >> ~/.bashrc && source ~/.bashrc

Non-printing characters in some manpages

I've noticed that some manpages have non-printing characters in them; for instance, std::rand has this line (should be 0):

Returns a pseudo-random integral value between拷,拷- and RAND_MAX (0 and RAND_MAX

According to grep, there's around 200 files that have the characters, which, comparing to the website versions, seem to almost always be characters in <span> tags, such as 0, a ;, a (, or whitespace, like the below:

  1. whitespace (I think)

    value of type Ret.ý¿¿½£¬

  2. ;

    bool pred()ý¿¿½£­

  3. (

    pointer decltypeý¿¿½£¬std::declval<Iter&>().operator->()) if valid,

Some unicode characters also don't seem to be handled correctly:

std::cout << "islower('拷,', C locale) returned "

It'd be nice if all of these could be parsed and rendered properly.

equations in docs

When I opened man page for std::normal_distribution I found out that the equation is not displayed correctly.
It looks like this:
f(x; μ,σ) =

              1
              σ
              √
              2π

              exp⎛
              ⎜
              ⎝

              -1
              2

              ⎛
              ⎜
              ⎝

              x-μ
              σ

              ⎞
              ⎟
              ⎠2
              ⎞
              ⎟
              ⎠

and it should be all in one line.

Configure options don't work

./configure --datarootdir $HOME/tmp/stdman/root/ --mandir $HOME/tmp/stdman/root/man
Configuring stdman
Platform: Linux

Reference location: ./reference/en/cpp
Install prefix: /usr/local
Install data prefix: /usr/local/share
Install man prefix: /usr/local/share/man
Temporary man location: ./man
Generation will be on 8 threads

Populating Makefile
Done configuring stdman

To install, use `sudo make install`

Can't open man page for std::ref and others

$ man std::ref
No manual entry for std::ref

while

$ man -k std::ref
std::ref,std::cref(3), std::ref(3), std::cref(3) - std::ref,std::cref
std::reference_wrapper(3) - std::reference_wrapper
std::reference_wrapper::get,std::reference_wrapper::operatorT&(3), std::reference_wrapper::get(3), std::reference_wrapper::operatorT&(3) - std::reference_wrapper::get,std::reference_wrapper::operatorT&
std::reference_wrapper::operator()(3) - std::reference_wrapper::operator()
std::reference_wrapper::operator=(3) - std::reference_wrapper::operator=
std::reference_wrapper::reference_wrapper(3) - std::reference_wrapper::reference_wrapper

The following works:

$ man std::ref,std::cref

New release

I'm considering creating a FreeBSD port (package) for this project so the tool can be easily installed via the OS package manager.
Would it be possible to get a new release given that the last one is from 2018?

operators could use better naming to be more accessible

Currently, bash will really get in the way when typing the operator names. For example:

$ man operator+,operator-(std::time_point)
bash: syntax error near unexpected token `(`

The current solution is to quote operators entirely.

$ man "operator+,operator-(std::time_point)"

A better solution could be made that just uses common short names for the operators, like operator lt, operator shr, et cetera.

No manual entry for member functions

Hi, i have a problem when using stdman.
I can only get man page of the class,
and get "no manual entry" message for all the member functions.

~$ man std::string::c_str
No manual entry for std::string::c_str

I refered to issue #22, and followed the Troubleshooting in README file.
still can not get it work. Could you help to check it?

  • os
~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial
  • the last few lines of man std::string
    image
  • files in install dir
~$ ls -ltr /usr/local/share/man/man3 | grep "std::string"
-rw-r--r-- 1 root root  534 Apr 11 22:04 std::hash(std::string_view,std::wstring_view,std::u16string_view,std::u32string_view).3.gz
-rw-r--r-- 1 root root  767 Apr 11 22:04 std::hash(std::string,std::wstring,std::u16string,std::u32string,std::pmr::string,.3.gz
-rw-r--r-- 1 root root 2603 Apr 11 22:04 std::string.3.gz
-rw-r--r-- 1 root root 2946 Apr 11 22:04 std::stringstream.3.gz
-rw-r--r-- 1 root root 2195 Apr 11 22:04 std::stringbuf.3.gz
-rw-r--r-- 1 root root  529 Apr 11 22:04 std::stringstream::operator=.3.gz
-rw-r--r-- 1 root root  319 Apr 11 22:04 std::stringstream::rdbuf.3.gz
-rw-r--r-- 1 root root  464 Apr 11 22:04 std::stringstream::swap.3.gz
  • configure in .bashrc
~$ cat ~/.bashrc | tail -n 2
export MANPAGER="/bin/sh -c \"col -b | vim -c 'set ft=man ts=8 nomod nolist nonu noma' -\""
export MANPATH=/usr/local/man:/usr/local/share/man:/usr/share/man:/usr/man

Suggestion to avoid need for MANPATH or installation in /usr/local

I thought I'd make an issue here out of the comment I left on the Arch AUR package for stdman, since making this change would be an improvement on all systems, not only Arch. (The issue there was that installing the manpages to the standard location conflicted with manpages provided by gcc, and my comment--this issue--provides a solution that would be useful to package maintainers as well as normal users.)


I updated the package to install the man pages to /usr/local. They do not really belong there, but at least this restores gcc compatibility.

While it's good that you're ensuring this package doesn't conflict with the gcc package, it is explicitly forbidden to install Arch packages under /usr/local1. In fact, you really want to install these manpages in the usual location so that users don't have to modify their MANPATH or change /etc/man_db.conf in order for man to be able to find them. Resolving the conflict is easy: append a suffix (perhaps cppref) to the section part of each manpage's filename. This is done all the time in order to deal with similar manpage conflicts:

arch-vm[1060]:~% pacman -Qo /usr/share/man/man1/passwd*
/usr/share/man/man1/passwd.1.gz is owned by shadow 4.6-1
/usr/share/man/man1/passwd.1ssl.gz is owned by openssl 1.1.0.i-1

Here's all the manpage (sub)sections currently on my system:

arch-vm[1061]:~% sed -rnz 's~^.*\.([[:print:]]+)\.gz$~\1~p' <(find /usr/share/man/man* -type f -print0) | sort -z | uniq -z | xargs -0 echo
0p 1 1m 1p 1perl 1ssl 2 3 3am 3cvc 3p 3pcap 3perl 3pm 3ssl 3t 3tiff 3x 4 5 5ssl 6 7 7ssl 8 n

Users can set MANSECT in their environment or change the SECTION directive in /etc/man_db.conf if they want to change which sections are searched and in what order.

Footnotes

  1. Even if this weren't the case, and even though the Arch FAQ says that Arch follows the specifications outlined in systemd's file-hierarchy(7) manpage rather than those of the FHS, the aforementioned manpage has no mention of /usr/local at all, so deferring to the longstanding convention (also explicitly codified by the FHS) that it exists for administrators to install stuff that they don't want the system package manager to touch would still be the best course of action.

mac

Hi, nice work. just an fyi, for mac installation, mandb doesnt exist, instead

sudo /usr/libexec/makewhatis

will do the trick.

std::cout?

Why can't I find things like cout?

man std::cout
No manual entry for std::cout

I get entries for std::string and std::iostream so I know the man pages installed.

Tag for 2022.02.01 missing?

It seems that with PR #46, the man pages have been updated to a newer version 2022.02.01 while the currently latest tag is 2021.12.21.

new tag release?

The latest release is 2018.03.11. How about a new one? Some managers use tags to update their packages.

The version may be synced by offline archives or others.

Minor cleanup coding format of <code>...</code>

<code>...</code> is still there. I'm not sure this tag should be automatically handled by asciidoctor, if so it should be some option to fully clean it up I guess.

At any rate, it would be great to clean this tag up.

PS. I'm using release tag 2018.03.11 if using latest commit, generated man page files' filename *.3 will also include template argument like std::something<Arg1,Arg2>:: .... (that is for another issue).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.