SF.net SVN: fclient: [409] trunk/sandbox/fcp2/scripts/gen_docs.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-06-28 08:22:51
|
Revision: 409
http://fclient.svn.sourceforge.net/fclient/?rev=409&view=rev
Author: jUrner
Date: 2008-06-28 01:23:00 -0700 (Sat, 28 Jun 2008)
Log Message:
-----------
new standalone version
Modified Paths:
--------------
trunk/sandbox/fcp2/scripts/gen_docs.py
Modified: trunk/sandbox/fcp2/scripts/gen_docs.py
===================================================================
--- trunk/sandbox/fcp2/scripts/gen_docs.py 2008-06-28 08:14:41 UTC (rev 408)
+++ trunk/sandbox/fcp2/scripts/gen_docs.py 2008-06-28 08:23:00 UTC (rev 409)
@@ -1,61 +1,75 @@
-"""Generates epydoc documentation for the package
+"""Generates epydoc documentation for the package in --> packageDir/doc
gen_docs.py
-@note: the script assumes it is located in the scripts subdirectory of the fcp package
+@note: the script assumes it is located in the <doc> or any other emidiate subdirectory of the package
@note: Use gen_docs.py -? or --help to print out this help text
+
+@requires: epydoc
"""
-from __future__ import with_statement
-
import sys, os
from epydoc import cli
import subprocess
+#************************************************************************************
+# consts
+#************************************************************************************
+PACKAGE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+DOC_DIR = os.path.join(PACKAGE_DIR, 'doc')
+EPYDOC_FOLDER = 'epydoc'
+EPYDOC_DIR = os.path.join(DOC_DIR, EPYDOC_FOLDER)
-#--> rel import hack
-class _RelImportHack(object):
- def __init__(self, n):
- fpath = os.path.abspath(__file__)
- for i in xrange(n): fpath = os.path.dirname(fpath)
- sys.path.insert(0, fpath)
- def __del__(self): sys.path.pop(0)
-hack = _RelImportHack(3)
+#************************************************************************************
+# helpers
+#************************************************************************************
+def save_create_dir(directory):
+ """creates a directory if it does not exist already"""
+ if not os.path.isdir(directory):
+ os.makedirs(directory)
+
+def enshure_doc_dir_dxists():
+ """enshures epydoc docdir exists"""
+ save_create_dir(EPYDOC_DIR)
+
+def pprint(msg, *params):
+ """helper to pprint user feedback"""
+ print '>' + msg
+ for i in params:
+ print ' ' + i
-from fcp2.scripts import fcpscripts_consts as consts
-
-
-del hack
-#<-- rel import hack
-#**************************************************************************************
-#
-#**************************************************************************************
+#**************************************************************************
+#
+#**************************************************************************
def main():
""""""
-
- consts.enshureDocDirExists()
- print 'calling epydoc'
+ pprint('dumping docs to:', EPYDOC_DIR)
+ enshure_doc_dir_dxists()
+ pprint('calling epydoc')
sys.argv = [
__file__,
'-v',
- '-o%s' % consts.EpydocDir,
+ '-o%s' % EPYDOC_DIR,
'--src-code-tab-width', '4',
#'--debug',
- consts.FcpDir,
+ PACKAGE_DIR,
]
cli.cli()
- print 'ok'
-
+
# create a redirect to 'epydoc/index.html'
- print 'creating redirect'
- with open(os.path.join(consts.DocDir, 'index.html'), 'w') as fp:
+ html_index = os.path.join(DOC_DIR, 'index.html')
+ pprint('creating redirect:', html_index)
+ fp = open(html_index, 'w')
+ try:
fp.write('''<html>
<head>
<meta http-equiv="Refresh" content="0; URL=%s">
</head>
</html>
-''' % (consts.EpydocFolder + '/' + 'index.html') )
+''' % (EPYDOC_FOLDER + '/' + 'index.html') )
+ finally:
+ fp.close()
- print 'done'
+ pprint('done')
#**************************************************************************************
#
@@ -64,8 +78,4 @@
wantsHelp = len(sys.argv) > 1 and sys.argv[1] or None
if wantsHelp not in ('-?', '--help'):
sys.exit(main())
-
print __doc__
-
-
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|