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:16 UTC
[1/3] lucy-clownfish git commit: Rework CFCPerlPod_md_to_pod
parameters
Repository: lucy-clownfish
Updated Branches:
refs/heads/master 613601b4e -> 8d82f9adc
Rework CFCPerlPod_md_to_pod parameters
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/65b1a324
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/65b1a324
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/65b1a324
Branch: refs/heads/master
Commit: 65b1a324dd398a3ae98c5e3e8deb19d55b6fe149
Parents: 613601b
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed Jul 8 15:32:54 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed Jul 8 18:15:32 2015 +0200
----------------------------------------------------------------------
compiler/perl/lib/Clownfish/CFC.xs | 10 ++++------
compiler/src/CFCPerlClass.c | 4 ++--
compiler/src/CFCPerlPod.c | 30 ++++++++++++++----------------
compiler/src/CFCPerlPod.h | 5 ++---
4 files changed, 22 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/65b1a324/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs
index 8e8f0f3..fb1f883 100644
--- a/compiler/perl/lib/Clownfish/CFC.xs
+++ b/compiler/perl/lib/Clownfish/CFC.xs
@@ -2414,17 +2414,15 @@ PPCODE:
SV*
-_md_to_pod(self, klass, source)
- CFCPerlPod *self;
+_md_to_pod(source, klass)
CFCClass *klass;
const char *source;
CODE:
- RETVAL = S_sv_eat_c_string(CFCPerlPod_md_to_pod(self, klass, source));
+ RETVAL = S_sv_eat_c_string(CFCPerlPod_md_to_pod(source, klass));
OUTPUT: RETVAL
SV*
-_gen_subroutine_pod(self, func, alias, klass, code_sample, class_name, is_constructor)
- CFCPerlPod *self;
+_gen_subroutine_pod(func, alias, klass, code_sample, class_name, is_constructor)
CFCFunction *func;
const char *alias;
CFCClass *klass;
@@ -2432,7 +2430,7 @@ _gen_subroutine_pod(self, func, alias, klass, code_sample, class_name, is_constr
const char *class_name;
int is_constructor;
CODE:
- char *value = CFCPerlPod_gen_subroutine_pod(self, func, alias, klass,
+ char *value = CFCPerlPod_gen_subroutine_pod(func, alias, klass,
code_sample, class_name,
is_constructor);
RETVAL = S_sv_eat_c_string(value);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/65b1a324/compiler/src/CFCPerlClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlClass.c b/compiler/src/CFCPerlClass.c
index dc1d234..8112328 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(pod_spec, client, raw_brief);
+ char *brief = CFCPerlPod_md_to_pod(raw_brief, client);
// 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(pod_spec, client, raw_description);
+ description = CFCPerlPod_md_to_pod(raw_description, client);
}
// Create SYNOPSIS.
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/65b1a324/compiler/src/CFCPerlPod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlPod.c b/compiler/src/CFCPerlPod.c
index 5a26ad5..9ef4bb8 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(CFCClass *klass, cmark_node *node);
+S_nodes_to_pod(cmark_node *node, CFCClass *klass);
static char*
S_pod_escape(const char *content);
static char*
-S_convert_link(CFCClass *klass, cmark_node *link);
+S_convert_link(cmark_node *link, CFCClass *klass);
static char*
S_pod_link(const char *text, const char *name);
@@ -181,7 +181,7 @@ CFCPerlPod_methods_pod(CFCPerlPod *self, CFCClass *klass) {
}
else {
meth_pod
- = CFCPerlPod_gen_subroutine_pod(self, (CFCFunction*)method,
+ = CFCPerlPod_gen_subroutine_pod((CFCFunction*)method,
meth_spec.alias, klass,
meth_spec.sample, class_name,
false);
@@ -223,7 +223,7 @@ CFCPerlPod_constructors_pod(CFCPerlPod *self, CFCClass *klass) {
else {
CFCFunction *init_func = CFCClass_function(klass, slot.func);
char *sub_pod
- = CFCPerlPod_gen_subroutine_pod(self, init_func, slot.alias, klass,
+ = CFCPerlPod_gen_subroutine_pod(init_func, slot.alias, klass,
slot.sample, class_name, true);
pod = CFCUtil_cat(pod, sub_pod, NULL);
FREEMEM(sub_pod);
@@ -233,7 +233,7 @@ CFCPerlPod_constructors_pod(CFCPerlPod *self, CFCClass *klass) {
}
char*
-CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, CFCFunction *func,
+CFCPerlPod_gen_subroutine_pod(CFCFunction *func,
const char *alias, CFCClass *klass,
const char *code_sample,
const char *class_name, int is_constructor) {
@@ -287,7 +287,7 @@ CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, 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(self, klass, long_doc);
+ char *perlified = CFCPerlPod_md_to_pod(long_doc, klass);
pod = CFCUtil_cat(pod, perlified, NULL);
FREEMEM(perlified);
}
@@ -298,7 +298,7 @@ CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, 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(self, klass, param_docs[i]);
+ char *perlified = CFCPerlPod_md_to_pod(param_docs[i], klass);
pod = CFCUtil_cat(pod, "=item *\n\nB<", param_names[i], "> - ",
perlified, NULL);
FREEMEM(perlified);
@@ -309,7 +309,7 @@ CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, 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(self, klass, retval_doc);
+ char *perlified = CFCPerlPod_md_to_pod(retval_doc, klass);
pod = CFCUtil_cat(pod, "Returns: ", perlified, NULL);
FREEMEM(perlified);
}
@@ -318,18 +318,16 @@ CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, CFCFunction *func,
}
char*
-CFCPerlPod_md_to_pod(CFCPerlPod *self, CFCClass *klass, const char *md) {
- (void)self; // unused
-
+CFCPerlPod_md_to_pod(const char *md, CFCClass *klass) {
cmark_node *doc = cmark_parse_document(md, strlen(md));
- char *pod = S_nodes_to_pod(klass, doc);
+ char *pod = S_nodes_to_pod(doc, klass);
cmark_node_free(doc);
return pod;
}
static char*
-S_nodes_to_pod(CFCClass *klass, cmark_node *node) {
+S_nodes_to_pod(cmark_node *node, CFCClass *klass) {
char *result = CFCUtil_strdup("");
if (node == NULL) {
return result;
@@ -441,7 +439,7 @@ S_nodes_to_pod(CFCClass *klass, cmark_node *node) {
case CMARK_NODE_LINK:
if (ev_type == CMARK_EVENT_ENTER) {
- char *pod = S_convert_link(klass, node);
+ char *pod = S_convert_link(node, klass);
result = CFCUtil_cat(result, pod, NULL);
FREEMEM(pod);
cmark_iter_reset(iter, node, CMARK_EVENT_EXIT);
@@ -533,10 +531,10 @@ S_pod_escape(const char *content) {
}
static char*
-S_convert_link(CFCClass *klass, cmark_node *link) {
+S_convert_link(cmark_node *link, CFCClass *klass) {
cmark_node *child = cmark_node_first_child(link);
const char *uri = cmark_node_get_url(link);
- char *text = S_nodes_to_pod(klass, child);
+ char *text = S_nodes_to_pod(child, klass);
char *retval;
if (!CFCUri_is_clownfish_uri(uri)) {
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/65b1a324/compiler/src/CFCPerlPod.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlPod.h b/compiler/src/CFCPerlPod.h
index c87c30d..e2352e4 100644
--- a/compiler/src/CFCPerlPod.h
+++ b/compiler/src/CFCPerlPod.h
@@ -99,8 +99,7 @@ const char*
CFCPerlPod_get_description(CFCPerlPod *self);
char*
-CFCPerlPod_md_to_pod(CFCPerlPod *self, struct CFCClass *klass,
- const char *source);
+CFCPerlPod_md_to_pod(const char *md, struct CFCClass *klass);
/** Autogenerate pod for either a Clownfish::CFC::Model::Method or a
* Clownfish::CFC::Model::Function.
@@ -113,7 +112,7 @@ CFCPerlPod_md_to_pod(CFCPerlPod *self, struct CFCClass *klass,
* argument handling is different for constructors.
*/
char*
-CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, struct CFCFunction *func,
+CFCPerlPod_gen_subroutine_pod(struct CFCFunction *func,
const char *alias, struct CFCClass *klass,
const char *code_sample,
const char *class_name, int is_constructor);
[2/3] lucy-clownfish git commit: Fix header levels in generated POD
Posted by nw...@apache.org.
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"
[3/3] lucy-clownfish git commit: No POD escapes needed in code blocks
Posted by nw...@apache.org.
No POD escapes needed in code blocks
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/8d82f9ad
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/8d82f9ad
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/8d82f9ad
Branch: refs/heads/master
Commit: 8d82f9adcc98ae0866d203eef53ea94a53b66955
Parents: e275a6c
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed Jul 8 15:47:21 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed Jul 8 18:16:40 2015 +0200
----------------------------------------------------------------------
compiler/src/CFCPerlPod.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8d82f9ad/compiler/src/CFCPerlPod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlPod.c b/compiler/src/CFCPerlPod.c
index 17315df..bc99a6a 100644
--- a/compiler/src/CFCPerlPod.c
+++ b/compiler/src/CFCPerlPod.c
@@ -382,17 +382,17 @@ S_nodes_to_pod(cmark_node *node, CFCClass *klass, int header_level) {
case CMARK_NODE_CODE_BLOCK: {
const char *content = cmark_node_get_literal(node);
- char *escaped = S_pod_escape(content);
+ char *copy = CFCUtil_strdup(content);
// Chomp trailing newline.
- size_t len = strlen(escaped);
- if (len > 0 && escaped[len-1] == '\n') {
- escaped[len-1] = '\0';
+ size_t len = strlen(copy);
+ if (len > 0 && copy[len-1] == '\n') {
+ copy[len-1] = '\0';
}
char *indented
- = CFCUtil_global_replace(escaped, "\n", "\n ");
+ = CFCUtil_global_replace(copy, "\n", "\n ");
result = CFCUtil_cat(result, " ", indented, "\n\n", NULL);
FREEMEM(indented);
- FREEMEM(escaped);
+ FREEMEM(copy);
break;
}