Adding HTML Documentation To Your Titanium Modules

Over the last few weeks I’ve been working on creating several Titanium modules.  To make life easier for myself and my users I’m using html for all of my documentation. The current Titanium 1.8.X module build script doesn’t yet support html documentation., which isn’t a big deal since you can add it into the zip directly.

The below script adds support for html into the build script itself.

  1. Open your build.py script located in the root of your module project.
  2. Look for def generate_doc(config)
  3. Replace that code block with the one below.

def generate_doc(config):
	docdir = os.path.join(cwd,'documentation')
	if not os.path.exists(docdir):
		print "Couldn't find documentation file at: %s" % docdir
		return None
	sdk = find_sdk(config)
	support_dir = os.path.join(sdk,'module','support')
	sys.path.append(support_dir)
	try:
		import markdown2 as markdown
	except ImportError:
		import markdown
	documentation = []
	for file in os.listdir(docdir):
		if file in ignoreFiles or os.path.isdir(os.path.join(docdir, file)):
			continue
		html = open(os.path.join(docdir,file)).read()
		if file.lower().endswith('.md'):
			html = markdown.markdown(html)
		else:
			documentation.append({file:html});

	return documentation

This solution worked for me, hopefully it will work for you.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,078 other followers

%d bloggers like this: