Documentation

  • Everyone hates to write it
  • Everyone loves it when they need it
  • The pleasure of a well-written man page
  • Examples: --help, man page, perldoc

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Good documentation must be:

 
  • Easy to write
  • Enforced socially
  • Enforced technically
  • Automatic as possible
  • Tested and used

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Easy to write

 
  • - Standards
  • - Examples
  • - Interfaces and tools

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Enforced socially

 
  • - It's a dirty job
  • - Making it fun

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Enforced technically

 
  • - The nag factor
  • - Don't just encourage, enforce
  • - Smoke testing

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Automatic as possible

 
  • - Creation, modification, review, collation

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Tested and used

 
  • - Share the burden (QA)
  • - Auditing

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


SELECT man('validate_ccnumber');

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Getting there

 
  • First solution: the comment field
  • COMMENT ON table dual IS 'This table is an ugly hack'
  • Available for all objects
  • Too generic - a single text field
  • This is a database after all

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


CREATE TABLE manpage (
  relation      oid,
  created_on    TIMESTAMPTZ NOT NULL DEFAULT now(),
  created_by    TEXT,
  last_modified TIMESTAMPTZ NOT NULL DEFAULT now(),
  summary       TEXT,
  description   TEXT,
  input         TEXT,
  output        TEXT
);

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Result:

 
  • Still fairly free-form, but with a little more structure
  • It is a little raw, so we will make a view for it
  • Note how the relation column expands into all sorts of other information:

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


CREATE VIEW man AS 
  SELECT n.nspname AS schema, c.relname AS "name", c.relkind AS kind,
    m.created_on, m.created_by, m.last_modified, m.summary, m.description,
    m.input, m.output, relation_version(n.nspname,c.relname) AS version
FROM manpage m, pg_class c, pg_namespace n, pg_type t
WHERE m.relation = c.oid
AND   c.relnamespace = n.oid

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

System catalogs

 
  • By directly linking to the system catalog, we allow good documentation to be created
  • The magical version function: cvs/subversion interface
  • SELECT man('valid_ccnumber');
  • SELECT man('public.valid_ccnumber');

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Back to the comment

 
  • Automatic insert on doc creation (triggers)
  • COMMENT ON TABLE dual IS 'Please do a SELECT man(''dual'') for full documentation';
  • More triggers: index, HTML, XML, etc.

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Technical enforcement

 
  • Is everyone playing nicely?
  • SELECT mancheck();
  • SELECT mancheck('schemaname');
  • SELECT mancheck('schemaname','object name');
  • Checks all user tables, views, function, triggers, domains, and operators
  • High details not necessary, except for functions
  • List the applications that use it, important dates, etc.
  • Also (or?) in the cvs logs for the schema
  • Enforcement: man -> mancheck

Next


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Close to the data

 
  • Better than cvs
  • Documentation lives close to the data
  • Exported with the data
  • If data is available, docs is available
  • Language independence

      Last             TOC             Next