diff --git a/Rakefile b/Rakefile index 7878929..3e6ef30 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/doc/Readme_for_developers.md b/doc/Readme_for_developers.md index 472c92d..8e8bdb8 100644 --- a/doc/Readme_for_developers.md +++ b/doc/Readme_for_developers.md @@ -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 diff --git a/gfm/sec12.md b/gfm/sec12.md index 8db1f1f..a0fe78d 100644 --- a/gfm/sec12.md +++ b/gfm/sec12.md @@ -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. diff --git a/image/state_diagram.png b/image/state_diagram.png new file mode 100644 index 0000000..9909b52 Binary files /dev/null and b/image/state_diagram.png differ diff --git a/image/state_diagram.xcf b/image/state_diagram.xcf new file mode 100644 index 0000000..5822432 Binary files /dev/null and b/image/state_diagram.xcf differ diff --git a/lib/lib_gen_main_tex.rb b/lib/lib_gen_main_tex.rb index 2e239f6..f9e1272 100644 --- a/lib/lib_gen_main_tex.rb +++ b/lib/lib_gen_main_tex.rb @@ -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 - elsif l != "\n" - preamble << l - end + if l =~ /\\begin{document}/ + break + elsif l != "\n" + preamble << l 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 diff --git a/src/sec12.src.md b/src/sec12.src.md index d2e6272..c94a463 100644 --- a/src/sec12.src.md +++ b/src/sec12.src.md @@ -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. diff --git a/src/tfetextview/tfetextview_doc.md b/src/tfetextview/tfetextview_doc.md index 82e68c6..cca958c 100644 --- a/src/tfetextview/tfetextview_doc.md +++ b/src/tfetextview/tfetextview_doc.md @@ -1,4 +1,4 @@ -# TfeTextView +# TfeTextView API reference TfeTextView -- Child widget of GtkTextView. It holds GFile the contents of GtkTextBuffer correponds to.