Skip to content

Commit

Permalink
generate: Refactor the global variable
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <ce.gao@outlook.com>
  • Loading branch information
gaocegege committed Jun 6, 2017
1 parent 9361704 commit 783be91
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)

# TODO: Refactor
template_dir = 'templates'
output_dir = 'docs'
content_dir = 'content'

img_dir = 'img'
property_dir = '.property.yml'

Expand Down Expand Up @@ -208,14 +203,28 @@ def generate_image(self, code, to):
@click.command()
@click.option('--core', default='', help='The location of Processing.R source code.')
@click.option('--jar', default='', help='The location of runner.jar')
def generate(core, jar):
@click.option('--docs-dir', default='', help='The location of Processing.R docs')
def generate(core, jar, docs_dir):
'''Generate Processing.R web reference.'''
# BUG: Fail to exit.
if core is None or jar is None:
click.echo('There is no core or jar.')
exit(1)
click.echo('The location of Processing.R source code:%s' % core)
click.echo('The location of Processing.R runner.jar: %s' % jar)
click.echo('The location of Processing.R docs: %s' % docs_dir)

template_dir_short = 'templates'
output_dir_short = 'docs'
content_dir_short = 'content'

global template_dir
global output_dir
global content_dir

template_dir = os.path.join(docs_dir, template_dir_short)
output_dir = os.path.join(docs_dir, output_dir_short)
content_dir = os.path.join(docs_dir, content_dir_short)

env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir), trim_blocks='true')

Expand Down

0 comments on commit 783be91

Please # to comment.