pg2docbook
- PostgreSQL-COMMENT to DocBook conversion
 
John Doe
Hans Schou

pg2docbook: - PostgreSQL-COMMENT to DocBook conversion
by John Doe and Hans Schou
Copyright © 2000 by Acme Inc. under "OpenContent" licensen

Table of Contents
1. Introduction	000
1.1. What is this?	000
2. Database	000
2.1. MyDB	000
2.1.1. Objects	000
2.1.1.1. List of tables	000
2.1.1.2. List of views	000
2.1.1.3. List of functions	000
2.1.2. Tables	000
2.1.2.1. Table: customer	000
2.1.2.2. Table: inventory	000
2.1.3. Views	000
2.1.3.1. View: custview	000
2.1.3.2. View: invenview	000
2.1.4. Functions	000
2.1.4.1. Function: getid(text)	000

List of Tables
2-1. customer	000
2-2. inventory	000

Chapter 1. Introduction
1.1. What is this?
pg2docbook is an application for converting PostgreSQL databases and comments to the DocBook format. In this way the database is documented together with the objects and can be converted to the readable formats DocBook supports.
See Chapter 2 for an example of how the documentation could look.

Chapter 2. Database
This text is located in start.sgml and is just a general description of the application databases.
2.1. MyDB
Date: 2000-12-31.
COMMENT ON DATABASE mydb IS 'Write comment here'
2.1.1. Objects
2.1.1.1. List of tables
•	customer Section 2.1.2.1
•	inventory Section 2.1.2.2
2.1.1.2. List of views
•	custview Section 2.1.3.1
•	invenview Section 2.1.3.2
2.1.1.3. List of functions
•	getid(text) Section 2.1.4.1
2.1.2. Tables
2.1.2.1. Table: customer
COMMENT ON TABLE customer IS 'Write comment here'
Table 2-1. customer
Column	Type	Description	
custid	int4	COMMENT ON COLUMN customer.custid IS 'Write comment here'	
name	text	COMMENT ON COLUMN customer.name IS 'Write comment here'	

2.1.2.2. Table: inventory
COMMENT ON TABLE inventory IS 'Write comment here'
Table 2-2. inventory
Column	Type	Description	
invid	int4	COMMENT ON COLUMN inventory.invid IS 'Write comment here'	
name	text	COMMENT ON COLUMN inventory.name IS 'Write comment here'	

2.1.3. Views
2.1.3.1. View: custview
COMMENT ON VIEW custview IS 'Write comment here'
CREATE VIEW custview AS 'SELECT * FROM customer WHERE name=''John'''
2.1.3.2. View: invenview
COMMENT ON VIEW invenview IS 'Write comment here'
CREATE VIEW invenview AS 'SELECT * FROM inventory WHERE name=''Chair'''
2.1.4. Functions
2.1.4.1. Function: getid(text)
COMMENT ON FUNCTION getid(text) IS 'Write comment here'
CREATE FUNCTION getid(text) RETURNS INT4 AS '
  DECLARE
    p_name ALIAS FOR $1;
    id INT4;
  BEGIN
    SELECT custid INTO id FROM customer WHERE name=p_name;
    IF NOT FOUND THEN
      RETURN 0;
    END IF;
    RETURN id;
  END;
' LANGUAGE 'PGplSQL';