News for hackers. Stuff that matters.
Re:Simplified and community-driven man pages by chao- on Sunday November 26, 2017 @01:47AM (#15779744)
I was lucky to first be introduced to man pages by someone who often just called them "manuals" and (to my best recollection) explained them by telling me "Manuals are to be read, top to bottom, contemplated, and maybe read again, before you act."

Thus I was never under the delusion that man pages were, or should strive to be, How-To's of some sort.

This TLDR tool definitely needs to exist, but in conjunction with man pages, not as a replacement. Manuals should continue to exist in a form that explores and explains the depths of a utility or command in whatever length that might require. I will make adequate use of both.

Re:Simplified and community-driven man pages by dfabulich on Sunday November 26, 2017 @02:14AM (#15779799)
The traditional structure of man pages (Synopsis, Description, Options, and maybe Examples at the end) is just Bad. No documentation expert would write doc this way, not even as a reference, say nothing of a tutorial.

The synopsis typically lists a bunch of command-line variations with literally no context, not even a line of commentary to tell the difference between the variations.

Then comes a description, which is fine, and then a list of options in alphabetical order which is almost always the least useful ordering. Categorize the parameters. Juxtapose confusingly similar options.

And only then do we get any examples, if any. The examples should have come first, in the synopsis.

There's nothing inherently wrong with man pages, but nobody has to follow this tradition. Put real examples in your synopsis and manually sort your options; you'll have a man page that's 20x better than most.

Re:Simplified and community-driven man pages by pletnes on Sunday November 26, 2017 @02:46AM (#15779887)
I disagree. man pages are optimized for time spent. The cryptic synopsis at the top is enough if I’m checking a frequently used command. The examples are at the bottom for newbies, which need to spend some time reading anyway.

man pages are not «good documentation», they are there for people who need to quickly figure out how to run a command. Good projects should have tutorials and complete references online in addition to man pages.

Re:Simplified and community-driven man pages by jmfayard on Sunday November 26, 2017 @03:41AM (#15780039)
A lot of us are "newbies" of "tar", "find", "[" and many others after years and years using *nix. According to the anti-usability mindset, this means that the users are wrong and ought to be changed, and not an hint that we should rethink how we write and consume documentation.

Edit: the wording was angrier than it needed to be. A concrete example of a better documentation tool : https://kapeli.com/dash

Re:Simplified and community-driven man pages by microcolonel on Sunday November 26, 2017 @04:19AM (#15780128)
For what it's worth, find is truly awful, and tar is just a bit unconventional in terms of option parsing. These are stand-out failures of interface design, for which no documentation would be sufficient for all but the most regular of users.
Re:Simplified and community-driven man pages by mjw1007 on Sunday November 26, 2017 @05:55AM (#15780334)
Note that the commonly-used GNU implementations of tar and find both have info documentation which is much better than the manpages.
Re:Simplified and community-driven man pages by minusf on Sunday November 26, 2017 @06:11AM (#15780373)
dash is web documentation kept offline with limited search added on top of it. it's basically a browser window...
Re:Simplified and community-driven man pages by dmitriid on Sunday November 26, 2017 @11:46AM (#15781669)
Which already makes it orders of magnitudes better than man
Re:Simplified and community-driven man pages by vthriller on Monday November 27, 2017 @04:54AM (#15786123)
But why? You already can search through man pages with / key in your $PAGER (more/less/most/vimpager), and across pages with `man -k`/`man -K`, and I wouldn't really call proportional fonts as "orders of magnitude" better.
Re:Simplified and community-driven man pages by rene_bg on Sunday November 26, 2017 @05:53AM (#15780328)
Thanks for the link to Kapeli/Dash - looks like something that could really make everyday work easier!
Re:Simplified and community-driven man pages by Annatar on Monday November 27, 2017 @07:16AM (#15786738)
Good projects should have tutorials and complete references online in addition to man pages.

A well written manual page requires no additional tutorials, for they will be included in the text’s corpus.

Writing good documentation for one’s software is almost more important than writing the software itself; don’t force the user to have to run around the internet; be comprehensive in the manual.

Re:Simplified and community-driven man pages by wodenokoto on Sunday November 26, 2017 @03:03PM (#15782684)
Why should good documentation not be bundled with the product?
Re:Simplified and community-driven man pages by pletnes on Wednesday November 29, 2017 @08:50AM (#15806709)
Sure. Cmake has a brief man page and a big bulky HTML manual.
Re:Simplified and community-driven man pages by microcolonel on Sunday November 26, 2017 @04:15AM (#15780112)
> not even as a reference

How are you supposed to write reference documentation without a section for describing the options which can be referred to by option name?

> The examples should have come first, in the synopsis.

Type with me: / E X A <return>. If anything, perhaps the first manual a man user should read is the manual for their default pager, usually LESS(1).

There are good and bad manpages, but I don't see how the format is truly deficient. Some very complex commands have separate sections for the most and least common options (or groups of related options, if there are subcommands or similar).

Re:Simplified and community-driven man pages by justin66 on Sunday November 26, 2017 @03:53PM (#15782930)
> The examples should have come first, in the synopsis.

That is just a terrible idea. First, if what you're putting in the synopsis is not "a brief summary or general survey of something" then the section is misnamed or the content does not belong there. Examples don't belong there. Second, and more importantly, plenty of commands can do enough damage that people ought to read up on what they do before receiving an example. You're giving someone a false sense of confidence if you throw an example at them first thing. That's appropriate enough in some contexts, but not in official documentation for software tools.

> The traditional structure of man pages (Synopsis, Description, Options, and maybe Examples at the end) is just Bad.

The problems you go on to list have nothing to do with the structure, and everything to do with the content contained within that structure.

> No documentation expert would write doc this way, not even as a reference, say nothing of a tutorial.

Since "documentation experts" write documentation this way, it's hard to imagine why you'd assert this.

Re:Simplified and community-driven man pages by xtiansimon on Monday November 27, 2017 @08:19AM (#15787051)
I share your reactions, with the exception that examples first or last seems irrelevant when using a man page—Sometimes it’s better first because you simply need a reminder how to use the command, and other times you need to read more of the description to catch the warnings before you use the command for the first or infrequent time. But if you follow the General best practice to read the whole of some documentation before you use a command, then this too seems irrelevant.

That said, if you’re writing, reviewing, and editing documentation, the traditional structure is hierarchical and consistent—-which is good.

Re:Simplified and community-driven man pages by jmfayard on Sunday November 26, 2017 @06:27AM (#15780419)
Man is like javadocs: useless unless you already know what you are doing, and then usually a wordy paraphrase of the method signature :(

Even as a reference manual, man is bad though.

If I'm looking for option "-e" of the test command, why can't I do

    $ man test -e
     -e file       True if file exists (regardless of type).

That seems more efficient, more unix-friendly and not too much to ask.

I get this is an historical tool that only cares about displaying the output of nroff. We would need a new tool with more empathy ($ woman? )

Re:Simplified and community-driven man pages by explainplease on Monday November 27, 2017 @07:54AM (#15786897)
> If I'm looking for option "-e" of the test command, why can't I do...

https://gist.github.com/alphapapa/3cba3ff196147ad42bac#file-...

    $ man test -e

           STRING1 != STRING2
                  the strings are not equal

           INTEGER1 -eq INTEGER2
                  INTEGER1 is equal to INTEGER2

           INTEGER1 -ge INTEGER2
                  INTEGER1 is greater than or equal to INTEGER2
    --

           INTEGER1 -ne INTEGER2
                  INTEGER1 is not equal to INTEGER2

           FILE1 -ef FILE2
                  FILE1 and FILE2 have the same device and inode numbers

           FILE1 -nt FILE2
                  FILE1 is newer (modification date) than FILE2
    --

           -d FILE
                  FILE exists and is a directory

           -e FILE
                  FILE exists

           -f FILE
                  FILE exists and is a regular file
Re:Simplified and community-driven man pages by kleiba on Sunday November 26, 2017 @07:47AM (#15780673)
De gustibus non est disputandum.

I've found javadocs enormously helpful when I was learning Java 20 years ago. But then again, I also like man pages and use them a lot.

If I'm looking for option "-e" of the test command, here's what I would do:

    $ man test
and then "/-e". Searching within a document is a commonly required skill in so many situations that I don't even think twice when applying it in man pages.

Of course, you could also just define a bash function for the functionality you're after like so:

    mano() {
        man "$1" | grep -A1 -- "$2"
    }
and then do

    $ mano test -e
or something along those lines.
Re:Simplified and community-driven man pages by jmfayard on Sunday November 26, 2017 @09:11AM (#15780953)
That's full text search, not having directly the argument definition. If you search "-l" in "man ls", it will be only your 8th occurence.
Re:Simplified and community-driven man pages by kleiba on Sunday November 26, 2017 @05:46PM (#15783526)
Sure, you're right, it's not the same thing. I just gave a simple example of something that's close, but I'm not even using a bash function like that myself. If I did, though, I guess the 8th occurrence wouldn't be so bad in my book, since the results can be scanned rather quickly.

You could always make your function more clever, e.g.:

    function mano() {
        man "$1" | grep -A1 -- "$2\\b"
    }
or

    function mano() {
        man "$1" | grep -A1 -- "$2  "
    }
but most probably, you will still run into edge cases that won't work properly. For instance, only one of the two versions above still works with "test -e".
Re:Simplified and community-driven man pages by nathyong on Sunday November 26, 2017 @05:53PM (#15783557)
You can actually search for ' -l' (two spaces in front) and abuse the man layout engine to find the point at which the flag itself is defined. Makes the man pages a lot more useful in my opinion.
Re:Simplified and community-driven man pages by wang_li on Sunday November 26, 2017 @04:42PM (#15783173)
If your idea of what man is comes from using Linux, then you really haven't had a good exposure to what good documentation can be. Try Solaris or FreeBSD.
Re:Simplified and community-driven man pages by Annatar on Monday November 27, 2017 @07:22AM (#15786767)
Indeed!
Re:Simplified and community-driven man pages by vram22 on Sunday November 26, 2017 @01:44PM (#15782312)
I agree with your point. There should be easier ways of doing some things in Unix. But since there are not (for some things, anyway, and I say this as a long-time Unix guy), sometimes, scripts can help. Here is one example by me:

m, a Unix shell utility to save cleaned-up man pages as text:

https://jugad2.blogspot.in/2017/03/m-unix-shell-utility-to-s...

This tiny script lets you generate man pages as cleaned-up text, saves them in a ~/man directory, and you can from then on, open them in your favorite text editor or even pager (less/more/pg/etc.) and view them. Created it out of real-life personal need some years ago, on a Unix system, but is still useful on Linux and other Unix-like systems today.

Re:Simplified and community-driven man pages by Annatar on Monday November 27, 2017 @07:21AM (#15786757)

  man test | grep -- ‘ -e’
UNIX already has that as you can see. You just need to learn the target substrate you’re using.
Re:Simplified and community-driven man pages by knolan on Sunday November 26, 2017 @05:56AM (#15780339)
Even though I've fallen out of love with Matlab, its documentation is excellent. Brief description of the syntax for quick reference, a more detailed description, and finally detailed examples. Often there are references to the academic work behind the function and links to broader topics. Finally there's a bunch of related functions listed at the end which is great for discovering the vast array of Matlab's capabilities.

For example: https://uk.mathworks.com/help/symbolic/svd.html

Re:Simplified and community-driven man pages by unixhero on Sunday November 26, 2017 @04:58AM (#15780207)
I agree. An an author of several command line tools I would never document it's usage in the way the classical man pages are structured. They are in times of dire need, frankly, unhelpful.

I ALWAYS have to Google it, since the man page gave me nothing.

Re:Simplified and community-driven man pages by Annatar on Monday November 27, 2017 @07:12AM (#15786724)
and maybe Examples at the end)

On a real UNIX like illumos and SmartOS, EXAMPLES are mandatory; I’ve no idea why people believe they may be optional, as they are one of the biggest reasons why someone would call up a manual page. It’s a manual.

Re:Simplified and community-driven man pages by onetruepretzel on Sunday November 26, 2017 @04:26AM (#15780144)
I must admit I'm not a fan of this. I feel like the work could go towards submitting patches to the man pages. The MAN page layout [0] allows for an EXAMPLES section which serves this purpose. Great effort in creating this tool but I think it's replicating functionality already provided by the man pages. I've submitted patches for MAN pages for GNU tools in the past and the creators are very receptive to updates.

[0] - https://en.wikipedia.org/wiki/Man_page#Layout

Re:Simplified and community-driven man pages by dmitriid on Sunday November 26, 2017 @11:48AM (#15781681)
Yup, and the examples section is usually last, with no possibility to jump directly to it
Re:Simplified and community-driven man pages by crispinb on Sunday November 26, 2017 @05:13PM (#15783352)
> and the examples section is usually last

A far better answer to this would have been a project to (1) improve man page examples, and then (2) create a small alternative man page client that displays only the examples (or puts them up top).

Having said that I do see the need for what tldr is doing, even though I would have preferred it added to existing tools. More often than not I only find man pages useful after I have needed to look up something. They're usually OK for wholistic understanding, but often too dense and assuming of far too much contextual knowledge to be useful in the heat of battle.

Re:Simplified and community-driven man pages by begriffs on Sunday November 26, 2017 @12:02PM (#15781766)
You can jump to it by typing /EXAMPLES<enter>

Or if that seems like a lot of keystrokes, /EX<enter> will probably jump to what you want most of the time too.

Re:Simplified and community-driven man pages by dmitriid on Monday November 27, 2017 @03:18AM (#15785661)
"probably"

   > man less

   /EX
   pattern not found

   /ex
   ends up somewhere in the middle of the text 
   on a word that contains ex
Re:Simplified and community-driven man pages by jforberg on Monday November 27, 2017 @06:57AM (#15786662)
> with no possibility to jump directly to it

How about '/examples'? Maybe you should take some time to actually learn how 'man' works before you start bashing it online...

Re:Simplified and community-driven man pages by explainplease on Monday November 27, 2017 @08:00AM (#15786934)

    $ cat ~/.bin/eg
    #!/bin/bash
    man $@ | awk '/^EXAMPLE/ { getline; while ($0 !~ /^[A-Z]+/) { print $0; getline; } }'
Re:Simplified and community-driven man pages by zaarn on Monday November 27, 2017 @04:05AM (#15785852)
Usually Shift-G should transport you to the end of the document.
Re:Simplified and community-driven man pages by jap on Sunday November 26, 2017 @02:42AM (#15779877)
I've integrated TLDR content into online man pages if you'd like to see both in one place. For example: https://www.mankier.com/1/grep
Re:Simplified and community-driven man pages by crispinb on Sunday November 26, 2017 @05:15PM (#15783364)
Good idea. I just suggested something very similar before seeing your comment. Now all you need to do is write this up as a shell command ;)
Re:Simplified and community-driven man pages by stinos on Sunday November 26, 2017 @03:38AM (#15780030)
just called them "manuals"

I'd be more specific: man vs tldr/bro is almost like an appliance's user manual vs service manual. The latter is super in depth but usually doesn't explain in an understandable way how to actually use the tool. While the former does that, but once you're stuck it offers no deeper explanation and you're lost.

Re:Simplified and community-driven man pages by agnivade on Monday November 27, 2017 @10:36AM (#15788087)
Maintainer here.

> This TLDR tool definitely needs to exist, but in conjunction with man pages, not as a replacement.

tldr is _exactly_ that. We do not and will not aim to replace man pages. We have a hard limit of 8 examples at max for every command. Therefore, our scope is very limited and we try to mention the 8 most important and practical examples a beginner needs to know for a command.

If someone needs to go deeper, man pages are always there.