Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lifeware
biocham
Commits
58458c6d
Commit
58458c6d
authored
Oct 19, 2015
by
Thierry Martinez
Browse files
Doc
parent
80cc71c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
doc.pl
View file @
58458c6d
...
...
@@ -369,17 +369,19 @@ generate_body_item(bibliography, _Doc, _Type) :-
% ).
generate_body_item_stream
(
Stream
,
Doc
,
Type
)
:-
generate_body_item_stream
(
Source
Stream
,
Stream
,
Type
)
:-
nb_setval
(
current_grammar
,
none
),
\
+
(
repeat
,
read_term
(
Stream
,
Clause
,
[
variables
(
Variables
),
variable_names
(
VariableNames
)]
SourceStream
,
Clause
,
[
variables
(
Variables
),
variable_names
(
VariableNames
)]
),
(
Clause
=
end_of_file
->
close_grammar
(
Doc
),
close_grammar
(
Stream
),
!
;
(
...
...
@@ -389,15 +391,16 @@ generate_body_item_stream(Stream, Doc, Type) :-
Type
=
devdoc
)
->
write_doc
(
Doc
,
Contents
)
write_doc
(
Stream
,
Contents
),
nl
(
Stream
)
;
Clause
=
(:-
grammar
(
Grammar
))
->
close_grammar
(
Doc
),
close_grammar
(
Stream
),
nb_setval
(
current_grammar
,
Grammar
),
make_id
(
Grammar
,
Id
),
format
(
Doc
,
Stream
,
'<table id="~a"><tr><td>~a ::= </td><td>\n'
,
[
Id
,
Grammar
]
)
...
...
@@ -413,11 +416,11 @@ generate_body_item_stream(Stream, Doc, Type) :-
Head
=..
[
Grammar
,
Item
]
->
instantiate_grammar_body
(
Body
),
format
(
Doc
,
'<div>| <code>~w</code></div>'
,
[
Item
])
format
(
Stream
,
'<div>| <code>~w</code></div>'
,
[
Item
])
;
close_grammar
(
Doc
),
close_grammar
(
Stream
),
name_variables_and_anonymous
(
Variables
,
VariableNames
),
generate_body_item_clause
(
Clause
,
Doc
,
Type
)
generate_body_item_clause
(
Clause
,
Stream
,
Type
)
),
fail
).
...
...
@@ -663,14 +666,16 @@ refer_argument(Argument, Doc) :-
write_doc_item
(
doc
(
DocBody
),
Stream
,
_Type
)
:-
write_doc
(
Stream
,
DocBody
).
write_doc
(
Stream
,
DocBody
),
nl
(
Stream
).
write_doc_item
(
devdoc
(
DocBody
),
Stream
,
Type
)
:-
(
Type
=
devdoc
->
write_doc
(
Stream
,
DocBody
)
write_doc
(
Stream
,
DocBody
),
nl
(
Stream
)
;
true
).
...
...
@@ -694,48 +699,47 @@ write_doc_item(biocham(Command), Stream, _Type) :-
).
write_doc
(
Doc
,
DocBody
)
:-
atom_chars
(
DocBody
,
DocChars
),
write_doc_chars
(
DocChars
,
Doc
),
write
(
Doc
,
'\n'
).
write_doc
(
Stream
,
Atom
)
:-
atom_chars
(
Atom
,
Chars
),
write_doc_chars
(
Chars
,
Stream
).
write_doc_chars
([],
_
).
write_doc_chars
([
'\\'
,
'\\'
|
Tail
],
Doc
)
:-
write_doc_chars
([
'\\'
,
'\\'
|
Tail
],
Stream
)
:-
!,
write
(
Doc
,
'\\'
),
write_doc_chars
(
Tail
,
Doc
).
write
(
Stream
,
'\\'
),
write_doc_chars
(
Tail
,
Stream
).
write_doc_chars
([
'\\'
|
Tail
],
Doc
)
:-
write_doc_chars
([
'\\'
|
Tail
],
Stream
)
:-
!,
parse_latex_command
(
Tail
,
Command
,
Argument
,
TailDoc
),
write_command
(
Command
,
Argument
,
Doc
),
write_doc_chars
(
TailDoc
,
Doc
).
write_command
(
Command
,
Argument
,
Stream
),
write_doc_chars
(
TailDoc
,
Stream
).
write_doc_chars
([
'-'
,
'-'
,
'-'
|
Tail
],
Doc
)
:-
write_doc_chars
([
'-'
,
'-'
,
'-'
|
Tail
],
Stream
)
:-
!,
write
(
Doc
,
'—'
),
write_doc_chars
(
Tail
,
Doc
).
write
(
Stream
,
'—'
),
write_doc_chars
(
Tail
,
Stream
).
write_doc_chars
([
'-'
,
'-'
|
Tail
],
Doc
)
:-
write_doc_chars
([
'-'
,
'-'
|
Tail
],
Stream
)
:-
!,
write
(
Doc
,
'–'
),
write_doc_chars
(
Tail
,
Doc
).
write
(
Stream
,
'–'
),
write_doc_chars
(
Tail
,
Stream
).
write_doc_chars
([
'<'
|
Tail
],
Doc
)
:-
write_doc_chars
([
'<'
|
Tail
],
Stream
)
:-
!,
write
(
Doc
,
'<'
),
write_doc_chars
(
Tail
,
Doc
).
write
(
Stream
,
'<'
),
write_doc_chars
(
Tail
,
Stream
).
write_doc_chars
([
'~'
|
Tail
],
Doc
)
:-
write_doc_chars
([
'~'
|
Tail
],
Stream
)
:-
!,
write
(
Doc
,
' '
),
write_doc_chars
(
Tail
,
Doc
).
write
(
Stream
,
' '
),
write_doc_chars
(
Tail
,
Stream
).
write_doc_chars
([
Char
|
Tail
],
Doc
)
:-
write
(
Doc
,
Char
),
write_doc_chars
(
Tail
,
Doc
).
write_doc_chars
([
Char
|
Tail
],
Stream
)
:-
write
(
Stream
,
Char
),
write_doc_chars
(
Tail
,
Stream
).
parse_latex_command
(
Chars
,
Command
,
Argument
,
Tail
)
:-
...
...
@@ -797,76 +801,84 @@ read_latex_command_arguments([], _ArgumentChars, _End, _Others) :-
throw
(
error
(
missing_closing_curly_braces
)).
write_command
(
texttt
,
Text
,
Doc
)
:-
write_command
(
texttt
,
Text
,
Stream
)
:-
!,
format
(
Doc
,
'<code>~a</code>'
,
[
Text
]).
format
(
Stream
,
'<code>~a</code>'
,
[
Text
]).
write_command
(
command
,
Command
,
Doc
)
:-
write_command
(
command
,
Command
,
Stream
)
:-
!,
make_id
(
Command
,
Id
),
format
(
Doc
,
'<a href="#~a"><code>~a</code></a>'
,
[
Id
,
Command
]).
format
(
Stream
,
'<a href="#~a"><code>~a</code></a>'
,
[
Id
,
Command
]).
write_command
(
argument
,
Argument
,
Doc
)
:-
write_command
(
argument
,
Argument
,
Stream
)
:-
!,
write
(
Doc
,
'<code>'
),
refer_argument
(
Argument
,
Doc
),
write
(
Doc
,
'</code>'
).
write
(
Stream
,
'<code>'
),
refer_argument
(
Argument
,
Stream
),
write
(
Stream
,
'</code>'
).
write_command
(
emph
,
Argument
,
Doc
)
:-
write_command
(
emph
,
Argument
,
Stream
)
:-
!,
write
(
Doc
,
'<em>'
),
write
(
Stream
,
'<em>'
),
atom_chars
(
Argument
,
ArgumentChars
),
write_doc_chars
(
ArgumentChars
,
Doc
),
write
(
Doc
,
'</em>'
).
write_doc_chars
(
ArgumentChars
,
Stream
),
write
(
Stream
,
'</em>'
).
write_command
(
index
,
Key
,
Doc
)
:-
write_command
(
index
,
Key
,
Stream
)
:-
!,
index
(
Doc
,
Key
),
index
(
Stream
,
Key
),
atom_chars
(
Key
,
KeyChars
),
write_doc_chars
(
KeyChars
,
Doc
).
write_doc_chars
(
KeyChars
,
Stream
).
write_command
(
begin
,
itemize
,
Doc
)
:-
write_command
(
begin
,
itemize
,
Stream
)
:-
!,
nb_setval
(
opened_li
,
false
),
write
(
Doc
,
'
<ul>'
).
write
(
Stream
,
'</div>\n
<ul>
\n
'
).
write_command
(
begin
,
enumerate
,
Doc
)
:-
write_command
(
begin
,
enumerate
,
Stream
)
:-
!,
nb_setval
(
opened_li
,
false
),
write
(
Doc
,
'
<ol>'
).
write
(
Stream
,
'</div>\n
<ol>
\n
'
).
write_command
(
item
,
Argument
,
Doc
)
:-
write_command
(
item
,
Argument
,
Stream
)
:-
!,
close_opened_li
(
Doc
),
write
(
Doc
,
'<li>'
),
close_opened_li
(
Stream
),
write
(
Stream
,
'<li>
<div>
'
),
atom_chars
(
Argument
,
ArgumentChars
),
write_doc_chars
(
ArgumentChars
,
Doc
).
write_doc_chars
(
ArgumentChars
,
Stream
).
write_command
(
end
,
itemize
,
Doc
)
:-
write_command
(
end
,
itemize
,
Stream
)
:-
!,
close_opened_li
(
Doc
),
write
(
Doc
,
'</ul>'
).
close_opened_li
(
Stream
),
write
(
Stream
,
'</ul>
\n<div>
'
).
write_command
(
end
,
enumerate
,
Doc
)
:-
write_command
(
end
,
enumerate
,
Stream
)
:-
!,
close_opened_li
(
Doc
),
write
(
Doc
,
'</ol>'
).
close_opened_li
(
Stream
),
write
(
Stream
,
'</ol>
\n<div>
'
).
write_command
(
example
,
Argument
,
Doc
)
:-
write_command
(
example
,
Argument
,
Stream
)
:-
!,
write
(
Doc
,
'</div><div><strong>Example.</strong> '
),
atom_chars
(
Argument
,
ArgumentChars
),
write_doc_chars
(
ArgumentChars
,
Doc
).
write
(
Stream
,
'</div>\n<div><strong>Example.</strong> '
),
write_doc
(
Stream
,
Argument
).
write_command
(
section
,
Argument
,
Stream
)
:-
!,
nb_getval
(
current_counters
,
Counters
),
length
(
Counnters
,
CounterCount
),
SectionLevel
is
CounterCount
+
2
,
format
(
Stream
,
'</div>\n<h~d>'
,
[
SectionLevel
]),
write_doc
(
Stream
,
Argument
)
format
(
Stream
,
'</h~d>\n<div>'
,
[
SectionLevel
]).
write_command
(
Command
,
_Argument
,
_
Doc
)
:-
write_command
(
Command
,
_Argument
,
_
Stream
)
:-
throw
(
error
(
unknown_command
(
Command
))).
close_opened_li
(
Doc
)
:-
close_opened_li
(
Stream
)
:-
(
nb_getval
(
opened_li
,
true
)
->
write
(
Doc
,
'
</li>'
),
write
(
Stream
,
'</div>
</li>
\n
'
),
nb_setval
(
opened_li
,
false
)
;
true
...
...
@@ -882,9 +894,9 @@ index_entry(UppercaseLetter, Key: Sections) :-
atom_codes
(
UppercaseLetter
,
[
UpperCode
]).
index
(
Doc
,
Key
)
:-
index
(
Stream
,
Key
)
:-
index_new_id
(
Key
,
Id
),
write
(
Doc
,
'<a id="~a" />'
,
[
Id
]).
write
(
Stream
,
'<a id="~a" />'
,
[
Id
]).
index_new_id
(
Key
,
Id
)
:-
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment