Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
docs: generate class doc from .md files
  • Loading branch information
perexg committed Apr 1, 2016
1 parent c9c6c0e commit 05c9cc2
Show file tree
Hide file tree
Showing 7 changed files with 1,438 additions and 20 deletions.
26 changes: 26 additions & 0 deletions Makefile
Expand Up @@ -537,6 +537,14 @@ BUNDLES-${CONFIG_DVBSCAN} += data/dvb-scan
BUNDLES = $(BUNDLES-yes)
ALL-$(CONFIG_DVBSCAN) += check_dvb_scan

#
# Documentation
#

MD-CLASS = $(patsubst docs/class/%.md,%,$(wildcard docs/class/*.md))
SRCS-yes += src/docs.c
I18N-C += src/docs_inc.c

#
# Internationalization
#
Expand Down Expand Up @@ -653,15 +661,33 @@ $(BUILDDIR)/build.o: $(BUILDDIR)/build.c
@mkdir -p $(dir $@)
$(pCC) -c -o $@ $<

# Documentation
$(BUILDDIR)/docs-timestamp: $(MD-FILES) support/doc/md_to_c.py
@-rm -f src/docs_inc.c
@for i in $(MD-CLASS); do \
echo "Markdown class: $${i}"; \
support/doc/md_to_c.py --in="docs/class/$${i}.md" \
--name="tvh_doc_$${i}_class" >> src/docs_inc.c; \
done
@touch $@

src/docs_inc.c: $(BUILDDIR)/docs-timestamp

$(BUILDDIR)/src/docs.o: src/docs_inc.c

# Internationalization
.PHONY: intl
intl:
@printf "Building tvheadend.pot\n"
@$(XGETTEXT2) -o intl/tvheadend.pot.new $(I18N-C)
@sed -e 's/^"Language: /"Language: en/' < intl/tvheadend.pot.new > intl/tvheadend.pot
$(MAKE) -f Makefile.webui LANGUAGES="$(LANGUAGES)" WEBUI=std intl
@printf "Building docs/tvheadend.pot\n"
@$(XGETTEXT2) -o intl/docs/tvheadend.pot.new $(I18N-DOCS)
@sed -e 's/^"Language: /"Language: en/' < intl/docs/tvheadend.pot.new > intl/docs/tvheadend.pot
$(MAKE)


intl/tvheadend.pot:

#intl/tvheadend.en_GB.po: intl/tvheadend.pot
Expand Down
10 changes: 10 additions & 0 deletions docs/class/access_entry.md
@@ -0,0 +1,10 @@
Setting up access control is an important initial step as **the system
is initially wide open**.

Tvheadend verifies access by scanning through all enabled access control
entries in sequence, from the top of the list to the bottom. The permission
flags, streaming profiles, DVR config profiles, channel tags and so on are
combined for all matching access entries. An access entry is said to match
if the username matches and the IP source address of the requesting peer
is within the prefix. There is also anonymous access, if the user is set
to asterisk. Only network prefix is matched then.
16 changes: 2 additions & 14 deletions src/access.c
Expand Up @@ -1433,26 +1433,14 @@ theme_get_ui_list ( void *p, const char *lang )
return strtab2htsmsg_str(tab, 1, lang);
}

static const char *access_entry_doc[] = {
N_("Setting up access control is an important initial step as "
"**the system is initially wide open**."),
N_("Tvheadend verifies access by scanning through all enabled access control "
"entries in sequence, from the top of the list to the bottom. "
"The permission flags, streaming profiles, DVR config profiles, "
"channel tags and so on are combined for all matching access entries. "
"An access entry is said to match if the username matches and the IP "
"source address of the requesting peer is within the prefix. There is "
"also anonymous access, if the user is set to asterisk. Only network "
"prefix is matched then."),
NULL
};
extern const char *tvh_doc_access_entry_class[];

const idclass_t access_entry_class = {
.ic_class = "access",
.ic_caption = N_("Access"),
.ic_event = "access",
.ic_perm_def = ACCESS_ADMIN,
.ic_doc = access_entry_doc,
.ic_doc = tvh_doc_access_entry_class,
.ic_save = access_entry_class_save,
.ic_get_title = access_entry_class_get_title,
.ic_delete = access_entry_class_delete,
Expand Down
7 changes: 7 additions & 0 deletions src/docs.c
@@ -0,0 +1,7 @@
#include <unistd.h>
//#include "tvh_locale.h"

#define LANGPREF "\xff"
#define N_(s) s

#include "docs_inc.c"
13 changes: 7 additions & 6 deletions src/webui/doc_md.c
Expand Up @@ -144,12 +144,14 @@ http_markdown_class(http_connection_t *hc, const char *clazz)
s = htsmsg_get_str(m, "caption");
if (s) {
md_header(hq, "##", s);
nl = 1;
nl = md_nl(hq, 1);
}
for (; *doc; doc++) {
md_nl(hq, 1);
md_text(hq, NULL, NULL, tvh_gettext_lang(lang, *doc));
md_nl(hq, 1);
if (*doc[0] == '\xff') {
htsbuf_append_str(hq, tvh_gettext_lang(lang, *doc + 1));
} else {
htsbuf_append_str(hq, *doc);
}
}
l = htsmsg_get_list(m, "props");
HTSMSG_FOREACH(f, l) {
Expand All @@ -158,8 +160,7 @@ http_markdown_class(http_connection_t *hc, const char *clazz)
s = htsmsg_get_str(n, "caption");
if (!s) continue;
if (first) {
md_nl(hq, 1);
md_nl(hq, 1);
nl = md_nl(hq, nl);
htsbuf_append_str(hq, "####");
htsbuf_append_str(hq, tvh_gettext_lang(lang, N_("Items")));
md_nl(hq, 1);
Expand Down

0 comments on commit 05c9cc2

Please sign in to comment.