Module: Dyndoc::Edit
- Defined in:
- lib/dyndoc-edit.rb
Class Method Summary collapse
- .docs_from_doc_tags_info(doc_tags_info) ⇒ Object
- .get_doc_tags(doc_tags_info) ⇒ Object
-
.get_doc_tags_info(content, current_tags = nil) ⇒ Object
if selected_tag is an Array, allow to get current tags to proces.
- .get_doc_tags_menu(doc_tags_info) ⇒ Object
- .get_docs(doc_tags_info) ⇒ Object
-
.html_file(doc, user = nil) ⇒ Object
doc=…, dyn_file: …, doc_tags_info: ….
-
.html_files(doc, user = nil) ⇒ Object
doc=…, doc_tags_info: ….
Class Method Details
.docs_from_doc_tags_info(doc_tags_info) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dyndoc-edit.rb', line 25 def Edit.() docs={} unless .empty? .split(",").each{|e| if e.strip =~ /^([^\(]*)(\([^\(\)]*\))?$/ docs[$1.strip]=($2 || "("+$1.strip+")")[1..-2].strip end } end return docs end |
.get_doc_tags(doc_tags_info) ⇒ Object
67 68 69 |
# File 'lib/dyndoc-edit.rb', line 67 def Edit.() Edit.get_docs().keys end |
.get_doc_tags_info(content, current_tags = nil) ⇒ Object
if selected_tag is an Array, allow to get current tags to proces
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dyndoc-edit.rb', line 38 def Edit.(content,=nil) ="" if content =~ /^\-{3}/ b=content.split(/^(\-{3,})/,-1) if b[0].empty? and b.length>4 tmp=b[2].strip.split("\n").select{|e2| e2.strip =~/^docs\:/} =tmp[0] || "" =$1.strip if =~ /^docs\:(.*)/ tmp=b[2].strip.split("\n").select{|e2| e2.strip =~/^only\:/} current_tag_info=tmp[0] || "" current_tag_info=$1.strip if current_tag_info =~ /^only\:(.*)/ p [:only_tag,current_tag_info] ## added possibility select current tags only when current_tags is provided as an Array if tmp[0] and and .is_a? Array =Edit.() current_tag_info.split(",").map{|e| e.strip}.each{|e| << e if .include? e} ##p [:only_current_tags,current_tags] end end end return end |
.get_doc_tags_menu(doc_tags_info) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/dyndoc-edit.rb', line 71 def Edit.() =Edit.() return "" if .empty? ="<div class=\"item\" data-value=\"\">default</div>"+.map{|e| "<div class=\"item\">"+e+"</div>"}.join("") ##p [:dropdown,doc_tags] end |
.get_docs(doc_tags_info) ⇒ Object
63 64 65 |
# File 'lib/dyndoc-edit.rb', line 63 def Edit.get_docs() Edit.() end |
.html_file(doc, user = nil) ⇒ Object
doc=…, dyn_file: …, doc_tags_info: …
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/dyndoc-edit.rb', line 79 def Edit.html_file(doc,user=nil) #doc={tag: ..., dyn_file: ..., doc_tags_info: ...} html_file=File.join(File.dirname(doc[:dyn_file]),File.basename(doc[:dyn_file],".*")+".html") docs=Edit.get_docs(doc[:doc_tags_info]) if !docs.empty? and docs.keys.include? doc[:tag] doc_extra=docs[doc[:tag]] if doc_extra[0,1]=="_" doc_extra +=doc[:tag] if doc_extra.length==1 html_file=File.join(File.dirname(doc[:dyn_file]),File.basename(doc[:dyn_file],".*")+doc_extra+".html") elsif doc_extra[0,1]=="~" # from user root if user html_file=File.join("/users",user,doc_extra[1..-1]+".html") end elsif doc_extra[0,1]=="/" # from global root html_file=File.join(doc_extra[1..-1]+".html") elsif !doc_extra.empty? html_file=File.join(File.dirname(doc[:dyn_file]),doc_extra+".html") end end return html_file end |
.html_files(doc, user = nil) ⇒ Object
doc=…, doc_tags_info: …
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/dyndoc-edit.rb', line 102 def Edit.html_files(doc,user=nil) #doc={dyn_file: ..., doc_tags_info: ...} html_files={} =[""]+Edit.(doc[:doc_tags_info]) doc2=doc.dup .each do |tag| doc2[:tag]=tag html_file=Edit.html_file(doc2,user) html_files[tag]=html_file end return html_files end |