The best I can do right now is to use the keyword global and to append each self.options to a list as we examine each occurrence of our custom directive.. It works, but I will be happier with docutils apis. I hacked the source code and I still can't find how to export that option keys.
This is useful because for some users like me, we don't need to publish HTML or anything. What we need is parsing. We just want to parse and get a list of dicts (each dict is one occurrence of the custom directive).

Thanks.

Cheer,
Yeukhon 

On Fri, Dec 28, 2012 at 11:58 PM, John Wong <gokoproject@gmail.com> wrote:
The code is on gist.github.
https://gist.github.com/4404545

I adapted this Foo code from someone else on the Internet. I am creating custom directive. 
My end goal is to retrieve option_spec back with key/value pair.

Suppose

.. foo::arg
    :prompt: Hello?
    :another-option: Hi

I want to get {'prompt': 'Hello?', 'another-option': 'Hi'} back. I don't need anything else, but that dictionary.
I browsed docutils source code but I am not sure how to fill in the required parameters for `docutils.parsers.rst.Directive`.__init__

Can someone please help? Thanks.

Yeukhon Wong