Add TfeTextView API reference in the tutorial. Add state diagram.

This commit is contained in:
Toshio Sekiya 2021-02-09 18:16:52 +09:00
parent 1b8e407d8d
commit 62d2fe46ba
8 changed files with 55 additions and 23 deletions

View file

@ -72,7 +72,7 @@ end
task html: ["html/index.html"]
file "html/index.html" => htmlfilenames do
file "html/index.html" => htmlfilenames+["html/tfetextview_doc.html"] do
buf = [ "# Gtk4 Tutorial for beginners\n", "\n" ]
src2md "src/abstract.src.md", "html/abstract.md", -1
File.open("html/abstract.md") do |file|
@ -96,6 +96,11 @@ file "html/index.html" => htmlfilenames do
add_head_tail_html "html/index.html"
end
file "html/tfetextview_doc.html" => "src/tfetextview/tfetextview_doc.md" do
sh "pandoc -o html/tfetextview_doc.html src/tfetextview/tfetextview_doc.md"
add_head_tail_html "html/tfetextview_doc.html"
end
0.upto(srcfiles.size - 1) do |i|
html_md = "html/#{srcfiles[i].to_md}"
html_html = "html/#{srcfiles[i].to_html}"
@ -131,8 +136,8 @@ end
task latex: ["latex/main.tex"]
file "latex/main.tex" => ["latex/abstract.tex"] + texpathnames do
gen_main_tex "latex", texfilenames
file "latex/main.tex" => ["latex/abstract.tex", "latex/tfetextview_doc.tex"] + texpathnames do
gen_main_tex "latex", texfilenames, ["tfetextview_doc.tex"]
end
file "latex/abstract.tex" => "src/abstract.src.md" do
@ -141,6 +146,10 @@ file "latex/abstract.tex" => "src/abstract.src.md" do
File.delete("latex/abstract.md")
end
file "latex/tfetextview_doc.tex" => "src/tfetextview/tfetextview_doc.md" do
sh "pandoc -o latex/tfetextview_doc.tex src/tfetextview/tfetextview_doc.md"
end
0.upto(srcfiles.size - 1) do |i|
file "latex/#{srcfiles[i].to_tex}" => (srcfiles[i].c_files << srcfiles[i].path) do
src2md srcfiles[i].path, "latex/#{srcfiles[i].to_md}", 86

View file

@ -149,17 +149,23 @@ Other words or expressions may be available in the future version.
## Conversion
The @@@ commands are carried out by scripts src2md.rb.
In addition, some conversion is made by srd2md.rb.
The @@@ commands are carried out by `src2md.rb`.
In addition, some conversion is made by `src2md.rb`.
- Relative links are changed according to the change of base directory.
- Size option in image link is left out when the destination is GFM or html.
- Relative link is left out when the destination is latex.
- Size option in image link is removed when the destination is GFM or html.
- Relative link is removed when the destination is latex.
- Lines in fence code block are folded when the destination is latex.
There's a method `src2md` in the `lib/lib_src2md.rb` script.
There's a method `src2md` in the `lib/lib_src2md.rb`.
This method converts src.md file into md file.
This method is used in `srd2md.rb` and `Rakefile`.
The script `src2md.rb` just invokes this method.
In the same way, the method is called in the action in `Rakefile`.
The code analyzing @@@if series command in the method is rather complicated.
It is based on the state diagram below.
![state diagram](../image/state_diagram.png)
## Directory structure

View file

@ -391,7 +391,10 @@ However, in Gtk4, `gtk_dialog_run`is unavailable any more.
The important thing is to duplicate `tv->file`.
Otherwise, if the caller frees the GFile object, `tv->file` is no more guaranteed to point the GFile.
## Source file of tfetextview.c
## API document and source file of tfetextview.c
Refer [API document of TfeTextView](../src/tfetextview/tfetextview_doc.md).
It is under the directory `src/tfetextview`.
All the source files are listed in [Section 15](sec15.md).
You can find them under [src/tfe5](../src/tfe5) and [src/tfetextview](../tfetextview) directories.

BIN
image/state_diagram.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

BIN
image/state_diagram.xcf Normal file

Binary file not shown.

View file

@ -1,7 +1,7 @@
# lib_gen_main_tex.rb
# -- Library ruby script to generate main.tex.
def gen_main_tex directory, texfilenames
def gen_main_tex directory, texfilenames, appendixfilenames
# parameter: directory: the destination directory to put generated files.
# texfilenames: an array of latex files. Each of them is "secXX.tex" where XX is digits.
@ -22,7 +22,7 @@ int main(int argc, char **argv) {
~~~
EOS
File.open("sample.md", "w") { |f| f.print sample_md }
File.write "sample.md", sample_md
if (! system("pandoc", "-s", "-o", "sample.tex", "sample.md"))
raise ("pandoc retuns error status #{$?}.\n")
end
@ -30,21 +30,19 @@ EOS
sample_tex.gsub!(/\\documentclass\[[^\]]*\]{[^}]*}/,"")
sample_tex.gsub!(/\\usepackage\[[^\]]*\]{geometry}/,"")
sample_tex.gsub!(/\\usepackage\[[^\]]*\]{graphicx}/,"")
sample_tex.gsub!(/\\setcounter{secnumdepth}{-\\maxdimen} % remove section numbering/,"")
sample_tex.gsub!(/\\author{[^}]*}/,"")
sample_tex.gsub!(/\\date{[^}]*}/,"")
preamble = []
in_preamble = true
sample_tex.each_line do |l|
if in_preamble
if l =~ /\\begin{document}/
in_preamble = false
break
elsif l != "\n"
preamble << l
end
end
end
preamble << "\\usepackage[margin=2.4cm]{geometry}"
preamble << "\\usepackage{graphicx}"
preamble << "\\usepackage[margin=2.4cm]{geometry}\n"
preamble << "\\usepackage{graphicx}\n"
File.write("#{directory}/helper.tex",preamble.join)
File.delete("sample.md")
File.delete("sample.tex")
@ -70,6 +68,11 @@ EOS
texfilenames.each do |filename|
main += " \\input{#{filename}}\n"
end
main += "\\newpage\n"
main += "\\appendix\n"
appendixfilenames.each do |filename|
main += " \\input{#{filename}}\n"
end
main += "\\end{document}\n"
IO.write("#{directory}/main.tex", main)
end

View file

@ -205,7 +205,18 @@ tfetextview/tfetextview.c tfe_text_view_get_file
The important thing is to duplicate `tv->file`.
Otherwise, if the caller frees the GFile object, `tv->file` is no more guaranteed to point the GFile.
## Source file of tfetextview.c
## API document and source file of tfetextview.c
@@@if gfm
Refer [API document of TfeTextView](tfetextview/tfetextview_doc.md).
It is under the directory `src/tfetextview`.
@@@elif html
Refer [API document of TfeTextView](../html/tfetextview_doc.html).
Its original markdown file is under the directory `src/tfetextview`.
@@@elif latex
Refer API document of TfeTextView in the appendix.
Its original markdown file is under the directory `src/tfetextview`.
@@@end
All the source files are listed in [Section 15](sec15.src.md).
You can find them under [src/tfe5](tfe5) and [src/tfetextview](../tfetextview) directories.

View file

@ -1,4 +1,4 @@
# TfeTextView
# TfeTextView API reference
TfeTextView -- Child widget of GtkTextView. It holds GFile the contents of GtkTextBuffer correponds to.