asciidoctor / asciidoctor-doctest

:hammer: Test suite for Asciidoctor backends
MIT License
12 stars 16 forks source link

Include level 0 title so each document is a fully valid document #4

Closed DavidGamba closed 9 years ago

DavidGamba commented 9 years ago

None of the test documents includes a = Level 0 heading which means they don't generate a fully valid output document as a result.

In the case of the manpage backend, not having the level 0 means the generated file can't be viewed without manually adding the header.

A tester can add his own adoc input files but it is easier if this is done in the provided examples.

WDYT?

jirutka commented 9 years ago

The level 0 heading has a special meaning in AsciiDoc. It’s called document title and unlike the section headings, it’s not related to the section node – the document title is rendered in document or embedded handler/template (at least in the case of HTML backends).

Therefore you can find it in the examples group document and embedded.

DavidGamba commented 9 years ago

Thanks, after playing more with it I realized it wasn't going to work. I can add a header to the output example and as long as it doesn't have the test identifier it won't affect the test result so I am covered.

Thank you for this framework, it is really helpful and speeds my dev process a lot :+1:

jirutka commented 9 years ago

I can add a header to the output example and as long as it doesn't have the test identifier it won't affect the test result so I am covered.

I don’t understand…? o.O

Thank you for this framework, it is really helpful and speeds my dev process a lot :+1:

I'm very glad to hear it! :smiley_cat:

DavidGamba commented 9 years ago

When I do rake generate for my manpage backend I get the following inline_menu.1 file:

." .menu
.PP
\fB File\fR

." .menuitem
.PP
\fBFile > Save\fR

." .submenu
.PP
\fBView > Zoom > Reset\fR

I can edit that file by adding a header:

.TH "Inline menu" 1
." .menu
.PP
\fB File\fR

." .menuitem
.PP
\fBFile > Save\fR

." .submenu
.PP
\fBView > Zoom > Reset\fR

And my tests still run properly and because it has the header I can see how man renders that file as well :-)

jirutka commented 9 years ago

Ah, I finally see what’s the problem! Manpage must start with a .TH header to be valid and so you can view the examples group in a manpage viewer.

Well, the serialize method in ExamplesSuite always generates a whole example group (i.e. examples file), so you can easily add some .TH header here. I suggest to put group_name to the .TH header.