summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Dittberner <jandd@cacert.org>2016-05-07 14:03:48 +0200
committerJan Dittberner <jandd@cacert.org>2016-05-07 14:03:48 +0200
commit031d5e8f85472348b985edf2b59f4b741e56a928 (patch)
treec44e350bf4452b5d4d43bd8f3287e619e01aa754
parent2b175af7f2449f05233f70a890a8d5a2717b5db6 (diff)
downloadcacert-infradocs-031d5e8f85472348b985edf2b59f4b741e56a928.tar.gz
cacert-infradocs-031d5e8f85472348b985edf2b59f4b741e56a928.tar.xz
cacert-infradocs-031d5e8f85472348b985edf2b59f4b741e56a928.zip
Sort functions in cacert sphinx extension
This commit sorts the functions in the sphinxext.cacert module: 1. class definitions for custom docutils node types 2. validation/conversion functions for directives 3. class definitions for custom docutils directives 4. helper functions for result node generation 5. Sphinx event handler functions 6. Sphinx setup function
-rw-r--r--docs/sphinxext/cacert.py140
1 files changed, 70 insertions, 70 deletions
diff --git a/docs/sphinxext/cacert.py b/docs/sphinxext/cacert.py
index f640ade..375bfe7 100644
--- a/docs/sphinxext/cacert.py
+++ b/docs/sphinxext/cacert.py
@@ -46,15 +46,6 @@ def sha1_fingerprint(argument):
return value
-def create_table_row(rowdata):
- row = nodes.row()
- for cell in rowdata:
- entry = nodes.entry()
- row += entry
- entry += cell
- return row
-
-
def is_valid_hostname(hostname):
if len(hostname) > 255:
return False
@@ -171,11 +162,81 @@ class CAcertSSHKeyList(Directive):
return []
+def create_table_row(rowdata):
+ row = nodes.row()
+ for cell in rowdata:
+ entry = nodes.entry()
+ row += entry
+ entry += cell
+ return row
+
+
def _create_interpreted_file_node(text, line=0):
return roles._roles['file']('', ':file:`%s`' % text,
text, line, None)[0][0]
+def _sslcert_item_key(item):
+ return "%s-%d" % (item['cn'], item['serial'])
+
+
+def _build_cert_anchor_name(cn, serial):
+ return 'cert_%s_%d' % (cn.replace('.', '_'), serial)
+
+
+def _format_subject_alternative_names(altnames):
+ return nodes.paragraph(text=", ".join(
+ [content for _, content in altnames]
+ ))
+
+
+def _place_sort_key(place):
+ return "%s-%d" % (place['docname'], place['lineno'])
+
+
+def _file_ref_paragraph(cert_info, filekey, app, env, docname):
+ para = nodes.paragraph()
+
+ places = [place for place in cert_info['places'] if place['primary']]
+ places.extend(sorted([
+ place for place in cert_info['places'] if not place['primary']],
+ key=_place_sort_key))
+
+ for pos in range(len(places)):
+ place = places[pos]
+ title = env.titles[place['docname']].astext().lower()
+ if place['primary'] and len(places) > 1:
+ reftext = nodes.strong(text=title)
+ else:
+ reftext = nodes.Text(title)
+ para += make_refnode(
+ app.builder, docname, place['docname'], place['target']['ids'][0],
+ reftext)
+ para += nodes.Text(":")
+ para += _create_interpreted_file_node(place[filekey])
+ if pos + 1 < len(places):
+ para += nodes.Text(", ")
+ return para
+
+
+def _format_serial_number(serial):
+ return nodes.paragraph(text="%d (0x%0x)" % (serial, serial))
+
+
+def _format_expiration_date(expiration):
+ return nodes.paragraph(text=expiration)
+
+
+def _format_fingerprint(fingerprint):
+ para = nodes.paragraph()
+ para += nodes.literal(text=fingerprint, classes=['fingerprint'])
+ return para
+
+
+def _get_cert_index_text(cert_info):
+ return "Certificate; %s" % cert_info['cn']
+
+
def process_sslcerts(app, doctree):
env = app.builder.env
if not hasattr(env, 'cacert_sslcerts'):
@@ -265,67 +326,6 @@ def process_sslcerts(app, doctree):
env.note_indexentries_from(env.docname, doctree)
-def _sslcert_item_key(item):
- return "%s-%d" % (item['cn'], item['serial'])
-
-
-def _build_cert_anchor_name(cn, serial):
- return 'cert_%s_%d' % (cn.replace('.', '_'), serial)
-
-
-def _format_subject_alternative_names(altnames):
- return nodes.paragraph(text=", ".join(
- [content for _, content in altnames]
- ))
-
-
-def _place_sort_key(place):
- return "%s-%d" % (place['docname'], place['lineno'])
-
-
-def _file_ref_paragraph(cert_info, filekey, app, env, docname):
- para = nodes.paragraph()
-
- places = [place for place in cert_info['places'] if place['primary']]
- places.extend(sorted([
- place for place in cert_info['places'] if not place['primary']],
- key=_place_sort_key))
-
- for pos in range(len(places)):
- place = places[pos]
- title = env.titles[place['docname']].astext().lower()
- if place['primary'] and len(places) > 1:
- reftext = nodes.strong(text=title)
- else:
- reftext = nodes.Text(title)
- para += make_refnode(
- app.builder, docname, place['docname'], place['target']['ids'][0],
- reftext)
- para += nodes.Text(":")
- para += _create_interpreted_file_node(place[filekey])
- if pos + 1 < len(places):
- para += nodes.Text(", ")
- return para
-
-
-def _format_serial_number(serial):
- return nodes.paragraph(text="%d (0x%0x)" % (serial, serial))
-
-
-def _format_expiration_date(expiration):
- return nodes.paragraph(text=expiration)
-
-
-def _format_fingerprint(fingerprint):
- para = nodes.paragraph()
- para += nodes.literal(text=fingerprint, classes=['fingerprint'])
- return para
-
-
-def _get_cert_index_text(cert_info):
- return "Certificate; %s" % cert_info['cn']
-
-
def process_sslcert_nodes(app, doctree, docname):
env = app.builder.env