Tk Library Source Code

View Ticket
Login
Ticket UUID: 1798427
Title: Doctools HTML output
Type: Bug Version: None
Submitter: sdeasey Created on: 2007-09-19 21:45:20
Subsystem: doctools Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2008-05-16 13:46:51
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2008-05-16 06:46:51
Description:

It is very difficult to make the HTML output of the dtplite command presentable.


- SECTION TITLES ARE IN ALL CAPS. It's traditional for man pages with limited formatting capability, but not necessary for a web page.

- The Table of Contents are indented with 4 non-breaking spaces and hard returns...

- The Synopsis is formatted using nested table. It's not necessary.

- Paragraphs and definition lists are unclosed.

- Examples are wrapped in a table so that a thick line will be drawn down the left edge. It's not necessary.

- dtplite is brittle in it's expectations for where things should live. For example, to use the automatic TOC and index building function I had to create a symlink forest of 'modules'. The directory names of the modules are used as the headings in the TOC.  It's not clear how to add C library docs to this.
User Comments: andreas_kupries added on 2008-05-16 13:46:51:
Logged In: YES 
user_id=75003
Originator: NO

Anchors for (sub)sections are now nicely generated (sectionNNN, subsectionNNN), nroff does automatic upper-casing of (sub)section titles, HTML doesn't do that any longer. The automatic sections (like keywords, see also, etc.) are now camel-cased instead of full uppercase. This completes the handling of this report.

andreas_kupries added on 2008-04-28 11:35:32:
Logged In: YES 
user_id=75003
Originator: NO

It seems section titling is the only thing I have left to do with this, and the generation of nice (sub)section ids.

Examples are now properly classed, without lots of tables and such. TOC and synopsis are now styled through the CSS as well, and a standard CSS is placed in the output. At least if the 'meta' engine parameter is not set. If it is it is assumed that its contents will specify their own style, be it internal, or external. Paragraph handling is now done into, through and in lists / list elements as well, so that should look nice too, now.

andreas_kupries added on 2008-04-23 02:47:20:
Logged In: YES 
user_id=75003
Originator: NO

Started to work on this again in the last few days (*) - cvs head now contains:
- sections, subsections are now closed. they are put in div's.
- examples are in divs (still have to drop the wrapping in table), sectref in spans.
- whole body in a div
- still to do: redoing toc and synopsis, embedded style, and lots of other small things.

(*) Now that I have a big set of formatting examples used by the testsuite to check the output.
    (see doctools/tests/man/* for the testcases, doctools/tests/html/* for the current results).

Regarding id's I have seen another way of generating them, in the tcler's wiki.
It uses the crc16 or crc32 of the section title, formatted as hex.
I believe an md5 would be better, more collision resistant. for subsections merge in the section title
predictable generation, no issues with any type of casing, no spaces, no dashes, no underlines.

andreas_kupries added on 2007-09-29 00:30:39:
Logged In: YES 
user_id=75003
Originator: NO

I found later that I am generating the id's by going to lower case, and replacing
spaces with underscores. Point taken regarding underscore/space vs. dash.

sdeasey added on 2007-09-28 07:56:40:
Logged In: YES 
user_id=87254
Originator: YES

Yes, I canonicalised ID's by bashing to lower case and replacing spaces with dashes.

I'm pretty sure you can't have spaces in ID names. If it were a class it would be considered two class names, but for ID's I'm pretty sure you can only have one anyway. Still, ID names are also used in fragments (the bit after the #hash in a URL) and in general it's a pain to have spaces there.

I used dashes instead of underscores again because of the URL fragment. URLs are often shown underlined and it's sometimes difficult to distinguish an underscore from a space when the word is underlined.

I forced to lowercase because of the requirement that nroff and html output titles in deferent cases. Probably best here to accept any input from the source, and force to uppercase for nroff, title case for html, and lower case for ID names. It's predictable for people generating URLs.

andreas_kupries added on 2007-09-28 01:41:56:
Logged In: YES 
user_id=75003
Originator: NO

Some clarifications ...

Wrapping sections into div's ... A bit more complicated than you might think, as I know when a section starts, but not immediately where it ends. May need state flags ... At least I have to number more than one place ...

id = section name ... you seem to actually use 'lower case section name'. what about spaces in the section name, is that allowed to be in the id too ? Or should we replace with underscore ?

'call' = 'def'. Not quite. 'call' wraps an anchor around the defined item, and puts the information into the synopsis. 'def' doesn't do these things. Beyond that they are identical, yes.

sdeasey added on 2007-09-27 01:49:19:
Logged In: YES 
user_id=87254
Originator: YES


Re formatting block level elements...


The auto-generated table of contents at the top of each page currently looks like this:


<h2><a name="table_of_contents">TABLE OF CONTENTS</a></h2>

<p>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#table_of_contents">TABLE OF CONTENTS</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#synopsis">SYNOPSIS</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#description">DESCRIPTION</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#commands">COMMANDS</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples">EXAMPLES</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#see_also">SEE ALSO</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#keywords">KEYWORDS</a><br>


(bug: note that "TABLE OF CONTENTS" appears twice; as a header and within the table of contents.. :-)


It probably should look something more like this:



<div id="table-of-contents" class="section">

  <h2>Table of Contents</h2>

  <ul>
    <li><a href="#synopsis">Synopsis</a></li>
    <li><a href="#description">Description</a></li>
    <li><a href="#commands">Commands</a></li>
    <li><a href="#examples">Examples</a></li>
    <li><a href="#see-also">See Also</a></li>
    <li><a href="#keywords">Keywords</a></li>
  </ul>

</div>



The synopsis should probably look something more like this:


<div id="synopsis" class="section">

  <h2>Synopsis</h2>

  <ul>
    <li><a href="#ns_sls-get"><strong class="cmd">ns_sls get</strong> <i class="arg">key</i> <span class="opt">?<i class="arg">value</i>?</span></a></li>
    ...
  </ul>

</div>



The commands sections currently looks like this:



<h2><a name="commands">COMMANDS</a></h2>
<p></p>

<dl>

<dt><a name="1"><b class='cmd'>ns_atprestartup</b> <i class='arg'>script</i> ?<i class='arg'>args</i>?</a></dt>
<dd>Pre-startup procs are called...
<br><br>
</dd>

<dt>...



It should look something more like this:



<div id="commands" class="section">

  <h2>Commands</h2>

  <dl class="definitions">
    <dt id="ns_atprestartup" class="call"><b class='cmd'>ns_atprestartup</b> <i class='arg'>script</i> <span class="opt">?<i class='arg'>args</i>?</span></dt>
    <dd>Pre-startup procs are called...</dd>

  </dl>
</div>



The pattern is:

- All sections have their own <div>, and the div wraps everything including the title

- They all have a class of 'section', and an id. An id is like a class, you can use it for styling. However, it must be unique within a page, and is the recommended way of linking within a document. So, this works: cmd.html#synopsis. 

- The id is the section name

- Definition lists seem to be reused within doctools, i.e. [call ...] is another way to say [def ...], so we add a class of 'call' to the <dt>, even though it already appears within a <dl> classed with 'definitions'.



The styling that used to be applied directly to the HTML elements can be moved to an embedded style sheet at the top of the page. If, the user passes a -style option to dtplite, the embedded styles are omitted and the link inserted.

For example, to some vertical space between each section, and indent the Table of Contents, the styles will look like this:

<head>
  <style type="text/css">
  <!--
    .section {margin-bottom: 2em;}
    #table-of-contents {padding-left: 4em;}
  -->
  </style>
</head>


The Table of Contents is a section, so it has both styles applied.



Also, the whole content section should be enclosed in a div, like so:


  <body>
    <div id="doctools"
      ...
    </div>
  </body>

andreas_kupries added on 2007-09-26 06:22:27:
Logged In: YES 
user_id=75003
Originator: NO

I think I am will use this bug report as the one where we can discuss HTML styling in general.
From the tcler's chat ...

[15:43]<RockShox>aku continuing from yesterday re doctools
[15:43]<RockShox>the class names dont matter as long as its documented
[15:45]akuI guess. I added lots of lcass names today, no docs however yet for them.
[15:52]<RockShox>its nice to have some divs too
[15:52]<RockShox>like around the toc
[15:52]<RockShox>or examples
[15:53]akuI have no idea what you can do with CSS, please file bug/enhancement reports with examples of how you wish to change the HTML
[15:55]<RockShox>you dont need to know what i can do with css
[15:55]<RockShox>you just need to give me a way to address the distinct parts of a doc
[15:55]<RockShox>if that makes sense
[15:56]<RockShox>it probably means most doctools commands should generate something within a div or an individual tag with a class name
[15:58]akuI may have phrased  my words badly too ... I have no idea what exactly you want me to put into the HTML which would support CSS. What is a div ? what attributes does it  have? things like that. I can work better when I see a concrete example of the change wanted, for this
[16:00]<RockShox>a div is just a division
[16:00]<RockShox>it doesnt really do much
[16:00]<RockShox>but if you give it a class then the css can distinguish anything within that div
[16:01]<RockShox>like i could make a link inside an example div different than a normal link
[16:01]<RockShox>by addressing that class
[16:05]akuso you are talking just about adding <div class=XXX>...</div> around certain things, or most things ?

What is your opinion about this ?

I am amenable to redo the generator to make it more accessible to CSS based styling.
This pertains to the items in the report here too. Will adding divs and classes make the nested table superfluous, to be added back if wanted by css, or overridable by CSS, or ... ?

andreas_kupries added on 2007-09-21 02:13:34:
Logged In: YES 
user_id=75003
Originator: NO

The closing of list elements (dt, dd, li) is now done. The closing of paragraphs is mainly done. Paragraphs in list elements do not get closed yet.

andreas_kupries added on 2007-09-20 23:50:32:
Logged In: YES 
user_id=75003
Originator: NO

Regarding section titles. They are passed through as is from the input, currently by all backends. If you do not write all-caps they will not be all-caps in the output ... Could the real request be that you wish to write your titles normally, and the nroff backend convert it to all-caps, with the html backend passing them unchanged, as it does now ?

Regarding the Table of contents. Do you have a concrete proposal or ideas for how the formatting of the TOC should be done instead ? Regarding the Synopsis the same question applies. Ditto regarding the formatting of examples.

Paragraphs. As far as I know that is legal HTML, although possibly not legal XHTML. I agree, closing them would be nicer. The same for definition lists. I have added these to my TODO lists.

dtplite has possibly quite rigid expectations. That is part of the reason it has the 'lite' moniker, as it made the implementation less complex. Is it possible for you to write up how your directory structure looked like, how dtplite behaved on it, and how your symlink forest helped in that regard ? Is it also possible to clarify the question on "how to add C library docs" a bit ? I have trouble understanding the problem with that ? From dtplite's perspective this would simply be another module in another directory. I think, if I interpret your question correctly.