本文整理匯總了Python中utils.rstcloth.rstcloth.RstCloth.field方法的典型用法代碼示例。如果您正苦於以下問題:Python RstCloth.field方法的具體用法?Python RstCloth.field怎麽用?Python RstCloth.field使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utils.rstcloth.rstcloth.RstCloth
的用法示例。
在下文中一共展示了RstCloth.field方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generate_params
# 需要導入模塊: from utils.rstcloth.rstcloth import RstCloth [as 別名]
# 或者: from utils.rstcloth.rstcloth.RstCloth import field [as 別名]
def generate_params(params, fn, conf):
r = RstCloth()
basename = os.path.basename(fn)
params.sort(key=lambda p: p['position'])
# Begin by generating the table for web output
r.directive('only', '(html or singlehtml or dirhtml)', block='htm')
r.newline(block='htm')
# { filename: { $name: <param> } }
ext_params = {}
processed_params = []
for param in params:
if 'file' in param:
pos = param['position']
if param['file'] not in ext_params:
fn, ext = populate_external_param(param['file'],
basename,
conf.paths.projectroot,
conf.paths.source)
ext_params[fn] = ext
param = ext_params[conf.paths.source + param['file']][param['name']]
param['position'] = pos
processed_params.append(param)
r.content(generate_param_table(processed_params), indent=3, block='html')
r.newline(block='htm')
# Then generate old-style param fields for non-web output
r.directive('only', '(texinfo or latex or epub)', block='tex')
r.newline(block='tex')
for param in processed_params:
key, val = generate_param_fields(param)
r.field(name=key, value=val, indent=3, wrap=False, block='tex')
r.newline(block='tex')
return r