You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/07/08 18:19:17 UTC
[2/3] lucy-clownfish git commit: Fix header levels in generated POD
Fix header levels in generated POD
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/e275a6cb
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/e275a6cb
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/e275a6cb
Branch: refs/heads/master
Commit: e275a6cb63b20c733cfb1bf6963c2429dc0d531d
Parents: 65b1a32
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed Jul 8 15:42:45 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed Jul 8 18:16:29 2015 +0200
----------------------------------------------------------------------
compiler/perl/lib/Clownfish/CFC.xs | 6 ++++--
compiler/src/CFCPerlClass.c | 4 ++--
compiler/src/CFCPerlPod.c | 26 +++++++++++++-------------
compiler/src/CFCPerlPod.h | 2 +-
compiler/src/CFCTestDocuComment.c | 2 +-
5 files changed, 21 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e275a6cb/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs
index fb1f883..d9e28bf 100644
--- a/compiler/perl/lib/Clownfish/CFC.xs
+++ b/compiler/perl/lib/Clownfish/CFC.xs
@@ -2414,11 +2414,13 @@ PPCODE:
SV*
-_md_to_pod(source, klass)
+_md_to_pod(source, klass, header_level)
CFCClass *klass;
const char *source;
+ int header_level;
CODE:
- RETVAL = S_sv_eat_c_string(CFCPerlPod_md_to_pod(source, klass));
+ RETVAL = S_sv_eat_c_string(CFCPerlPod_md_to_pod(source, klass,
+ header_level));
OUTPUT: RETVAL
SV*
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e275a6cb/compiler/src/CFCPerlClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlClass.c b/compiler/src/CFCPerlClass.c
index 8112328..91c34a8 100644
--- a/compiler/src/CFCPerlClass.c
+++ b/compiler/src/CFCPerlClass.c
@@ -357,7 +357,7 @@ CFCPerlClass_create_pod(CFCPerlClass *self) {
// Get the class's brief description.
const char *raw_brief = CFCDocuComment_get_brief(docucom);
- char *brief = CFCPerlPod_md_to_pod(raw_brief, client);
+ char *brief = CFCPerlPod_md_to_pod(raw_brief, client, 2);
// Get the class's long description.
char *description;
@@ -367,7 +367,7 @@ CFCPerlClass_create_pod(CFCPerlClass *self) {
}
else {
const char *raw_description = CFCDocuComment_get_long(docucom);
- description = CFCPerlPod_md_to_pod(raw_description, client);
+ description = CFCPerlPod_md_to_pod(raw_description, client, 2);
}
// Create SYNOPSIS.
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e275a6cb/compiler/src/CFCPerlPod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlPod.c b/compiler/src/CFCPerlPod.c
index 9ef4bb8..17315df 100644
--- a/compiler/src/CFCPerlPod.c
+++ b/compiler/src/CFCPerlPod.c
@@ -60,13 +60,13 @@ static const CFCMeta CFCPERLPOD_META = {
};
static char*
-S_nodes_to_pod(cmark_node *node, CFCClass *klass);
+S_nodes_to_pod(cmark_node *node, CFCClass *klass, int header_level);
static char*
S_pod_escape(const char *content);
static char*
-S_convert_link(cmark_node *link, CFCClass *klass);
+S_convert_link(cmark_node *link, CFCClass *klass, int header_level);
static char*
S_pod_link(const char *text, const char *name);
@@ -287,7 +287,7 @@ CFCPerlPod_gen_subroutine_pod(CFCFunction *func,
// Incorporate "description" text from DocuComment.
const char *long_doc = CFCDocuComment_get_description(docucomment);
if (long_doc && strlen(long_doc)) {
- char *perlified = CFCPerlPod_md_to_pod(long_doc, klass);
+ char *perlified = CFCPerlPod_md_to_pod(long_doc, klass, 3);
pod = CFCUtil_cat(pod, perlified, NULL);
FREEMEM(perlified);
}
@@ -298,7 +298,7 @@ CFCPerlPod_gen_subroutine_pod(CFCFunction *func,
if (param_names[0]) {
pod = CFCUtil_cat(pod, "=over\n\n", NULL);
for (size_t i = 0; param_names[i] != NULL; i++) {
- char *perlified = CFCPerlPod_md_to_pod(param_docs[i], klass);
+ char *perlified = CFCPerlPod_md_to_pod(param_docs[i], klass, 3);
pod = CFCUtil_cat(pod, "=item *\n\nB<", param_names[i], "> - ",
perlified, NULL);
FREEMEM(perlified);
@@ -309,7 +309,7 @@ CFCPerlPod_gen_subroutine_pod(CFCFunction *func,
// Add return value description, if any.
const char *retval_doc = CFCDocuComment_get_retval(docucomment);
if (retval_doc && strlen(retval_doc)) {
- char *perlified = CFCPerlPod_md_to_pod(retval_doc, klass);
+ char *perlified = CFCPerlPod_md_to_pod(retval_doc, klass, 3);
pod = CFCUtil_cat(pod, "Returns: ", perlified, NULL);
FREEMEM(perlified);
}
@@ -318,16 +318,16 @@ CFCPerlPod_gen_subroutine_pod(CFCFunction *func,
}
char*
-CFCPerlPod_md_to_pod(const char *md, CFCClass *klass) {
+CFCPerlPod_md_to_pod(const char *md, CFCClass *klass, int header_level) {
cmark_node *doc = cmark_parse_document(md, strlen(md));
- char *pod = S_nodes_to_pod(doc, klass);
+ char *pod = S_nodes_to_pod(doc, klass, header_level);
cmark_node_free(doc);
return pod;
}
static char*
-S_nodes_to_pod(cmark_node *node, CFCClass *klass) {
+S_nodes_to_pod(cmark_node *node, CFCClass *klass, int header_level) {
char *result = CFCUtil_strdup("");
if (node == NULL) {
return result;
@@ -369,9 +369,9 @@ S_nodes_to_pod(cmark_node *node, CFCClass *klass) {
case CMARK_NODE_HEADER:
if (ev_type == CMARK_EVENT_ENTER) {
- int header_level = cmark_node_get_header_level(node);
+ int extra_level = cmark_node_get_header_level(node) - 1;
char *header = CFCUtil_sprintf("=head%d ",
- header_level + 2);
+ header_level + extra_level);
result = CFCUtil_cat(result, header, NULL);
FREEMEM(header);
}
@@ -439,7 +439,7 @@ S_nodes_to_pod(cmark_node *node, CFCClass *klass) {
case CMARK_NODE_LINK:
if (ev_type == CMARK_EVENT_ENTER) {
- char *pod = S_convert_link(node, klass);
+ char *pod = S_convert_link(node, klass, header_level);
result = CFCUtil_cat(result, pod, NULL);
FREEMEM(pod);
cmark_iter_reset(iter, node, CMARK_EVENT_EXIT);
@@ -531,10 +531,10 @@ S_pod_escape(const char *content) {
}
static char*
-S_convert_link(cmark_node *link, CFCClass *klass) {
+S_convert_link(cmark_node *link, CFCClass *klass, int header_level) {
cmark_node *child = cmark_node_first_child(link);
const char *uri = cmark_node_get_url(link);
- char *text = S_nodes_to_pod(child, klass);
+ char *text = S_nodes_to_pod(child, klass, header_level);
char *retval;
if (!CFCUri_is_clownfish_uri(uri)) {
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e275a6cb/compiler/src/CFCPerlPod.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlPod.h b/compiler/src/CFCPerlPod.h
index e2352e4..1d63a4a 100644
--- a/compiler/src/CFCPerlPod.h
+++ b/compiler/src/CFCPerlPod.h
@@ -99,7 +99,7 @@ const char*
CFCPerlPod_get_description(CFCPerlPod *self);
char*
-CFCPerlPod_md_to_pod(const char *md, struct CFCClass *klass);
+CFCPerlPod_md_to_pod(const char *md, struct CFCClass *klass, int header_level);
/** Autogenerate pod for either a Clownfish::CFC::Model::Method or a
* Clownfish::CFC::Model::Function.
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e275a6cb/compiler/src/CFCTestDocuComment.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestDocuComment.c b/compiler/src/CFCTestDocuComment.c
index be970b4..99bcc95 100644
--- a/compiler/src/CFCTestDocuComment.c
+++ b/compiler/src/CFCTestDocuComment.c
@@ -243,7 +243,7 @@ S_test_generator(CFCTest *test) {
"\n"
"=head1 DESCRIPTION\n"
"\n"
- "=head3 Heading 1\n"
+ "=head2 Heading 1\n"
"\n"
"Paragraph: I<emphasized>, B<strong>, C<code>.\n"
"\n"