<?xml version="1.0" standalone="no"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
                  "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<!-- standalone="no" verifies that this document uses an external DTD. -->
<!-- DOCTYPE indicates what the root element for this document is. HOWTO documents are typically articles, and so use the article element as the root element. -->
<!-- PUBLIC specifies the public identifier for the DTD. -->
<!-- The system identifier comes next, and is the URL for the DTD. -->

<!-- This is a quick little workaround pointing to a local copy of the DTD, which can be useful when the web is too slow. -->
<!-- <!DOCTYPE article SYSTEM "tools/docbook/docbookx.dtd"> -->

<!-- ROOT ELEMENT -->
<!-- HOWTO documents will almost always be articles. -->
<article id="darwin-documentation-howto" lang="en">


<!-- ARTICLE INFO -->
<articleinfo>
  <title>The Darwin Documentation HOWTO</title>
  <author>
    <firstname>Ron</firstname>
    <surname>Hayden</surname>
      <affiliation>
        <jobtitle>Senior Tools Manager</jobtitle>
        <orgname>Apple Technical Publications</orgname>
    	<address><email>rhayden@apple.com</email>
    	</address>
    </affiliation>
  </author>  

  <!-- REVISION HISTORY -->
  <!-- Provide a revision element for each revision. -->
  <revhistory>  
    <revision>
      <revnumber>3</revnumber>
      <date>19 March 2002</date>    
      <authorinitials>ms - murray@freebsd.org</authorinitials>
      <revremark>Added references to the documentation mailing list and the man pages HowTo.</revremark>        
    </revision>	     	     
    <revision>
      <revnumber>2</revnumber>
      <date>20 July 2001</date>    
      <authorinitials>rjh</authorinitials>
      <revremark>Updated XML editor list and man page status.</revremark>        
    </revision>	     	     
   <revision>
      <revnumber>1</revnumber>
      <date>25 January 2001</date>    
      <authorinitials>rjh - rhayden@apple.com</authorinitials>
      <revremark>Initial release.</revremark>        
    </revision>	     	     
  </revhistory>
  
  <!-- ABSTRACT -->
  <abstract>
    <para>What you need to know to contribute to the Darwin
      documentation project.</para>

    <para>This HOWTO will grow as we develop processes and tools. If
      you have any suggestions for improving it, email
      <email>rhayden@apple.com</email>.</para>
  </abstract>
</articleinfo>

<!-- SECTION 1 -->
<!-- This is a top-level section, which can contain subsections. -->
<!-- You can have as many sect1s in your document as you wish. -->
<!-- Each sect should include a unique text identifier, which allows linking directly to that section. -->

  <sect1 id="state-of-the-world">
    <title>The state of the world</title>

    <para>The focus of this discussion is on the details of
      contributing HowTo documents. But first a bit of the big
      picture. At this point in the life of Darwin there are three
      types of documentation we are set up to handle, listed in the
      order that we're tackling them:</para>

    <!-- Typical list -->
    <para>
    <itemizedlist>
      <listitem><para>HeaderDoc</para></listitem>
      <listitem><para>HowTo documents</para></listitem>
      <listitem><para>man pages</para></listitem>
    </itemizedlist>
    </para>

    <para>We'd love to have your contribution in any of these areas,
      or your suggestions for whatever other kinds of documents we
      should have.  If you are interested in writing documentation
      about Darwin, please join the
      <email>darwin-documentation@lists.apple.com</email> mailing
      list.</para>
	
    <para>To join the Darwin Documentation list or any other
      Darwin-related list, see <ulink
      url="http://lists.apple.com/mailman/listinfo">http://lists.apple.com/mailman/listinfo</ulink>.</para>
 
<!-- SECTION 2 -->
<!-- This is a sub-section. You can have as many sect2s as you wish under a sect1. -->
<!-- You can also continue nesting sub-sections, down to sect5. -->

    <sect2 id="headerdoc">
      <title>HeaderDoc</title>

      <para>If you are writing code for Darwin, you should be using
        HeaderDoc.</para>
	
      <para>HeaderDoc is an Open Source Perl tool for embedding
        structured commentary in C and C++ header files and producing
        rich HTML output from that commentary. HeaderDoc comments are
        similar in appearance to JavaDoc comments in a Java source
        file, but there are differences related to handling specifics
        of C and C++ and a slightly more formal tag set to simplify
        parsing.</para>
	
      <para>A simple HeaderDoc comment for a function might look like
        this:</para>
	
      <!-- CODE LISTING -->
      <para>
      <programlisting>/*!
  @function HMBalloonRect
  @discussion Gets information about the size of a help balloon.
  @param inMessage The help message for the help balloon. 
  @param outRect The coordinates of the rectangle enclosing the balloon.
*/
OSErr HMBalloonRect (const HMMessageRecord *inMessage, Rect *outRect);</programlisting>
      </para>

      <para>These comments are extracted and poured into a
        nicely-rendered HTML frameset that allows quick access to the
        reference comments.</para>
	
      <para>To find out more about HeaderDoc, go to</para>

      <para><ulink
        url="http://www.opensource.apple.com/projects/headerdoc/">http://www.opensource.apple.com/projects/headerdoc/</ulink></para>
	
      <para>You can join the HeaderDoc mailing lists at</para>

      <para><ulink
        url="http://www.opensource.apple.com/projects/mail.html">http://www.opensource.apple.com/projects/mail.html</ulink></para>

    </sect2>

    <sect2 id="howto-documents">
      <title>HowTo documents</title>

      <para>The rest of this document will cover authoring HowTo
        documents.</para>
    </sect2>

    <sect2 id="man-pages">
      <title>man pages</title>

      <para>man pages are currently going through a number of changes.
        The <ulink
        url="http://www.opensource.apple.com/projects/documentation/howto/html/man_page_HOWTO.html">Darwin
        Man Page HOWTO</ulink> is essential reading if you are
        interested in working on man pages.  Currently, the man pages
        themselves are being moved from a centralized project to live
        with the commands they document. General responsibility for
        man pages are being moved from the writers to the
        engineers.</para>
    </sect2>
  </sect1>

  <sect1 id="questions">
    <title>Questions you should ask first</title>

    <sect2 id="documentation-license">
      <title>What license is used for Darwin documentation?</title>

      <para>HowTo documents included in the Darwin project are covered
        by the <citetitle>Common Documentation License</citetitle>
        (CDL), which you can review here:</para>
	
      <para><ulink
        url="http://www.opensource.apple.com/cdl/">http://www.opensource.apple.com/cdl/</ulink></para>

      <para>HeaderDoc and man pages are considered to be a part of the
        software, covered by the <citetitle>Apple Public Source
        License</citetitle> (APSL) or other applicable software
        license(s).</para>
    </sect2>

    <sect2 id="who-can-submit-documentation">
      <title>Who can submit documentation?</title>

      <para>You! Who better? If you know about a subject that seems to
        be sorely lacking in documentation, then go ahead and write up
        a HowTo and send it to
        <email>darwin-documentation@lists.apple.com</email> or to
        <email>rhayden@apple.com</email>. If you can only cover part
        of a subject, do that part and send it in. Someone else is
        much more likely to help finish it if it's been
        started.</para>
    </sect2>

    <sect2 id="dont-know-xml">
      <title>What if I don't know how to author an XML document?</title>

      <para>Keep reading! This document provides everything you need
        to know to get started. If after reading the XML instructions
        you still find yourself having trouble, just let us
        know.</para>
    </sect2>

    <sect2 id="dont-want-xml">
      <title>What if I don't <emphasis>want</emphasis> to learn XML?</title>

      <para>We're much more concerned with getting the information out
        to people than with what format you provide it in. So if you'd
        prefer not to venture into XML, provide it in whatever way
        works best for you and we'll get around to putting it into XML
        for you.</para>
	
      <para>Everything eventually has to end up as XML to support
        automated processing of the document into multiple
        formats.</para>
    </sect2>

    <sect2 id="who-can-change-documents">
      <title>Who can make changes to existing documents?</title>

      <para>Although the documentation is maintained as Open Source,
	we assume that the original author is interested in providing
	the primary maintenance for the document, and in guiding the
	nature of any changes and bug fixes.  Therefore suggestions,
	changes, and bug fixes should be sent to the original author
	so they can decide how best to integrate them.</para>
	
      <para>If there is no response, or the author is no longer
        interested in maintaining the document, or there's no obvious
        author, then send your comments to
        <email>darwin-documentation@lists.apple.com</email> or to
        <email>rhayden@apple.com</email> and they will get
        handled.</para>
    </sect2>

    <sect2 id="documentation-mailing-list">
      <title>Where is the documentation mailing list?</title>

      <para>We don't have a doc-specific mailing list at this
        time. Until the documentation project gains its own momentum,
        we will simply use
        <email>Darwin-Development@lists.apple.com</email>.</para>

      <para>A Documentation-specific mailing list is now available.
        Please join the
        <email>darwin-documentation@lists.apple.com</email> mailing
        list, in addition to any general purpose Darwin lists that
        interest you.</para>
    </sect2>
  </sect1>

  <sect1 id="authoring-a-howto-document">
    <title>Authoring a HowTo document</title>

    <para>The HowTo documents are authored in XML, using the DocBook
      XML DTD. They are maintained in the Darwin CVS archive and will
      soon be built regularly.</para>

    <sect2 id="what-is-xml">
      <title>What is XML?</title>

      <para>XML is a structured document language that describes text
        according to what kind of data it is, rather than how it
        should look. If you are used to simply making text bold when
        you want it to be bold, then it can take a bit of adjustment
        to understand the XML authoring model.</para>
	
      <para>In traditional text editors if you wanted to make
        someone's email address stand out in a paragraph, you would
        provide some special formatting.  In an RTF document you might
        make it bold, or if you are editing an HTML document, you
        might look up the formatting for a mailTo anchor so poeple can
        click on the address to send email. XML makes your life
        easier. All you need to do is identify the data as an email
        address, such as <sgmltag
        class="starttag">email</sgmltag>rhayden@apple.com<sgmltag
        class="endtag">email</sgmltag>, and when the document is
        processed the tools decide what to do. So for RTF it might
        become bold, for HTML it might become a hot link.</para>
	
      <para>With a structured editing language like XML, the writer's
        job changes to one of providing content and identifying what
        that content is. How the content is produced is handled
        seperately.</para>
	
      <para>Authoring XML is a bit like programming. After you create
        a document, you need a 'compiler' to parse it and make sure it
        is a legal document, so that the production tools will be able
        to do their job. This is known as validating the
        document. Some editors will do the validation for you, but
        many do not and require you to use a separate tool.</para>
	
    </sect2>

    <sect2 id="choosing-an-xml-editor">
      <title>Choosing an XML editor</title>

      <para>Given the young nature of XML there are not a lot of
        high-quality editors to be found. Hopefully this situation
        will change soon. The important features to consider in an
        editor are:</para>
	
      <itemizedlist>
	<listitem><para>automatic tag insertion</para></listitem>
	<listitem><para>tag constraints: not allowing you to use
          illegal tags while editing</para></listitem>
	<listitem><para>validation against the Document Type
          Definition (DTD)</para></listitem>
      </itemizedlist>
	
      <para>If you don't find an XML editor you like that provides
        validation or tag constraints, then don't worry about it and
        just use your favorite editor. You'll just have to do a bit of
        work when you do run a validating parser on your document, to
        clean up any errors you've made.</para>
	
      <para>Editors you might want to check out are:</para>

      <itemizedlist>

	<listitem><para>ElfData's XML Editor, a commercial XML editor
          for the Mac and Mac OS X at <ulink
          url="http://www.elfdata.com/xmleditor/">http://www.elfdata.com/xmleditor/</ulink>.
          ElfData has made it a priority for their editor to work for
          the Documentation Project, and has added a number of
          features specifically for the project such as DocBook
          support.</para></listitem>

	<listitem><para>PSGML editing mode for Emacs, at <ulink
          url="http://www.lysator.liu.se/~lenst/about_psgml/psgml.html">http://www.lysator.liu.se/~lenst/about_psgml/psgml.html</ulink>.</para></listitem>

	<listitem><para>Morphon XML Editor, <ulink
          url="http://www.morphon.com/">http://www.morphon.com/</ulink>.</para></listitem>

	<listitem><para>Emile, a commercial XML editor for the Mac, at
          <ulink
          url="http://www.in-progress.com/emile/">http://www.in-progress.com/emile/</ulink>.</para></listitem>

        <listitem><para>XMLWriter, a commercial XML editor for
          Windows, at <ulink
          url="http://xmlwriter.net/">http://xmlwriter.net/</ulink>.</para></listitem>
      </itemizedlist>

      <para>There are a couple of free GUI-based XML editors in
        development:</para>
	
      <itemizedlist>
	<listitem><para>IBM's java-based Xeena editor, <ulink
          url="http://www.alphaworks.ibm.com/tech/xeena">http://www.alphaworks.ibm.com/tech/xeena</ulink>.</para></listitem>

	<listitem><para>The Conglomerate system, <ulink
          url="http://www.conglomerate.org/">http://www.conglomerate.org/</ulink>.</para></listitem>

      </itemizedlist>
    </sect2>

    <sect2 id="getting-the-docbook-dtd">
      <title>Getting the DocBook DTD</title>

      <para>Now that you have an editor, you need the Document Type
        Definition (DTD). The DocBook DTD is available at the Oasis
        site, <ulink
        url="http://www.oasis-open.org/docbook/xml">http://www.oasis-open.org/docbook/xml</ulink>.</para>

      <para>Make sure you get the XML DTD, not the SGML
        version.</para>

      <para>Technically you don't need to have this on your local
        system, given that your XML document can point to it on the
        web (as the released versions of the HOWTO documents do). You
        may find that during the authoring of a document it's faster
        and more convenient to point your document to a local copy of
        the DTD. The HOWTO template provides an example of
        this.</para>
    </sect2>

    <sect2 id="learning-the-docbook-dtd">
      <title>Learning the DocBook DTD</title>

      <para>DocBook is the standard DTD used for creating technical
        documentation in the Open Source world. It's highly flexible,
        which means you can create documents as diverse as an API
        reference or this HowTo article with it.</para>

      <para>This flexibility also leads to the criticism that DocBook
	has too many tags and is too complex for a mere human to
	use. Norm Walsh has responded to this with a simplified
	DocBook DTD, at <ulink
	url="http://www.nwalsh.com/docbook/simple/index.html">http://www.nwalsh.com/docbook/simple/index.html</ulink>,
	which you can use if you prefer.</para>

      <para>While DocBook can be complex if you are authoring API
	reference or using tables, the typical HowTo document is
	really quite easy to author. This document so far has used
	less than ten unique tags for the body text (the author and
	revision information do use a few extra tags, but that's the
	kind of thing you can just copy anyway).</para> <para>Here are
	some good tutorials and other resources to get you started
	using DocBook. Some of these may refer to the SGML version,
	which is practically identical except for using a different
	identifier at the top and using mixed-case tags:</para>
	
      <itemizedlist>

	<listitem><para><citetitle pubwork="book">DocBook: The
          Definitive Guide</citetitle>, <ulink
          url="http://docbook.org/tdg/html/docbook.html">http://docbook.org/tdg/html/docbook.html</ulink></para></listitem>

	<listitem><para><citetitle pubwork="book">Writing
          Documentation Using DocBook</citetitle>, <ulink
          url="http://public.lst.de/~eric/index.html">http://public.lst.de/~eric/index.html</ulink></para></listitem>

	<listitem><para><citetitle pubwork="book">Get Going With
          DocBook</citetitle>, <ulink
          url="http://nis-www.lanl.gov/~rosalia/mydocs/docbook-intro/docbook-intro.html">http://nis-www.lanl.gov/~rosalia/mydocs/docbook-intro/docbook-intro.html</ulink></para></listitem>

        <listitem><para><citetitle pubwork="book">A Practical
          Introduction to DocBook</citetitle>, <ulink
          url="http://www.oswg.org/oswg-nightly/oswg/en_US.ISO_8859-1/articles/DocBook-Intro/docbook-intro/index.html">http://www.oswg.org/oswg-nightly/oswg/en_US.ISO_8859-1/articles/DocBook-Intro/docbook-intro/index.html</ulink></para></listitem>

	<listitem><para><citetitle pubwork="book">FreeBSD
          Documentation Project Primer for New
          Contributors</citetitle>, <ulink
          url="http://www.freebsd.org/tutorials/docproj-primer/">http://www.freebsd.org/tutorials/docproj-primer/</ulink></para></listitem>

      </itemizedlist>
    </sect2>

    <sect2 id="using-the-howto-template">
      <title>Using the HOWTO template</title>

      <para>The XML version of this document serves as a pretty
        comprehensive template for HOWTOs. However, that's a lot of
        deleting to do to get started on your own writing. You might
        find it easier to use the Darwin HOWTO Template, which you can
        get here:</para>

      <para><ulink
        url="http://www.opensource.apple.com/projects/documentation/howto/xml/Darwin_HOWTO_Template.xml">http://www.opensource.apple.com/projects/documentation/howto/xml/Darwin_HOWTO_Template.xml</ulink>.</para>

    </sect2>

    <sect2 id="processing-xml">
      <title>Processing XML</title>

      <para>Creating an XML document is one thing, but processing it
        into HTML or PDF is another. There are multiple tools used in
        the process, and many alternatives to choose from, most of
        which are in various states of development.</para>

      <para>The Darwin Documentation project is still setting up the
        build system, and the tools used are subject to change at any
        time. Right now, we use the following:</para>

      <itemizedlist>

	<listitem><para>Norm Walsh's XSL stylesheets, <ulink
          url="http://www.nwalsh.com/docbook/xsl/index.html">http://www.nwalsh.com/docbook/xsl/index.html</ulink></para></listitem>

	<listitem><para>James Clark's Java-based XSLT engine, XT,
          <ulink
          url="http://www.jclark.com/xml/xt.html">http://www.jclark.com/xml/xt.html</ulink></para></listitem>

	<listitem><para>James Clark's XML parser, XP, <ulink
	  url="http://www.jclark.com/xml/xp/index.html">http://www.jclark.com/xml/xp/index.html</ulink></para></listitem>

      </itemizedlist>

      <para>With these tools installed, your CLASSPATH needs to
	include pointers to xt.jar, xp.jar, and sax.jar, similar to
	this:</para>

      <programlisting>CLASSPATH=xt.jar:xp.jar:sax.jar</programlisting>
	
      <para>The Java command to transform the XML into HTML looks like
        this, where the docbook_xsl directory is the location of the
        xsl stylesheets:</para>

      <programlisting>java com.jclark.xsl.sax.Driver myfile.xml
        docbook_xsl/html/docbook.xsl &gt; myfile.html</programlisting>

      <para>Given that this solution is Java-based, it cannot
        currently be run on the Darwin release. We're looking into
        some Perl-based solutions and other alternatives to change
        that in the near future.</para>
    </sect2>
  </sect1>

  <sect1>
    <title>Copyright</title>

    <para>Copyright &copy; 2001 by Apple Computer, Inc.</para>

    <para>This material has been released under and is subject to the
      terms of the Common Documentation License, v.1.0, the terms of
      which are hereby incorporated by reference. Please obtain a copy
      of the License at <ulink
      url="http://www.opensource.apple.com/cdl/">http://www.opensource.apple.com/cdl/w</ulink>
      and read it before using this material. Your use of this
      material signifies your agreement to the terms of the
      License.</para>
  </sect1>
</article>
