asciidoctor / atom-language-asciidoc

⚛ AsciiDoc language package for the Atom editor.
https://atom.io/packages/language-asciidoc
MIT License
42 stars 20 forks source link

add template for man page to snippets #112

Closed mojavelinux closed 8 years ago

mojavelinux commented 8 years ago

Man pages require a special document structure. This snippet gets you started.

mojavelinux commented 8 years ago

Also removed the file too.adoc that accidentally got committed.

nicorikken commented 8 years ago

This functionality and it's proper usage was new to me. The use-case itself not of course 😉 A very nice showcase of the power of Asciidoc, having to define name and author only once, whilst it is rendered multiple times. Here is a basic example I tried to test this snippet, based on the example in the Asciidoctor user manual.

= {name}(1)
Andrew Stanton
v1.0.0
:doctype: manpage
:name: eva
:man manual: User Commands
:man source: {revnumber}

== NAME

{name} - analyzes an image to determine if it's a picture of a life form

== SYNOPSIS

*{name}* ['OPTION']... 'FILE'...

== OPTIONS

*-o, --out-file*::
  Write results to file.

== EXIT STATUS

*0*::
  Success.

*1*::
  Failure.

== COPYRIGHT

Copyright \(C) {author}.

This is free software.
See the source for copying conditions.

Renders like:

screen shot 2016-05-12 at 20 29 12

I think this can be merged.

ldez commented 8 years ago

Cool feature!

Only one question: it's a real commons case?

mojavelinux commented 8 years ago

Only one question: it's a real commons case?

Very common for teams that use AsciiDoc primarily for man pages, such as the git project. It's also one of the trickiest document structures to type from scratch, so the template here saves tons of time. My hope is that it also means people will make more man pages, which we need in this world.

mojavelinux commented 8 years ago

having to define name and author only once, whilst it is rendered multiple times.

Indeed, this is one of the main DRY powers of AsciiDoc.

As it turns out, it is possible to have the template edit the same text in multiple places by using the syntax ${1:name} multiple times in the template. However, there's no reason to do this since AsciiDoc already has support for reusable text. But something to keep in mind for the future.

ldez commented 8 years ago

@mojavelinux Can you rebase ?

mojavelinux commented 8 years ago

You bet!

mojavelinux commented 8 years ago

Done!