automatically generating table of contents

See the following -

Writing Documentation with AsciiDoc

I discovered AsciiDoc while writing Learn Linux in a Month of Lunches. AsciiDoc is a fantastically thorough markup language for writing books—think Markdown, but with more options, such as sidebars, notes, and tables. AsciiDoc lets you just type, with simple syntax controlling the formatting. When I first started writing my book, I was using Word style sheets with LibreOffice. Manning, my publisher, offered .odt versions for OpenOffice, but I had trouble getting the styles to work...