Skip to content

Instantly share code, notes, and snippets.

@reasonset
Created April 18, 2016 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reasonset/bdff0625ad84a3594fea079caa12b694 to your computer and use it in GitHub Desktop.
Save reasonset/bdff0625ad84a3594fea079caa12b694 to your computer and use it in GitHub Desktop.
diff --git a/README.md b/README.md
index dc3f176..6f79d20 100644
--- a/README.md
+++ b/README.md
@@ -168,3 +168,25 @@ Copy `config_sample/accs` as a ACCS directory and configure what you want.
Build this ACCS.
Please execute in an ACCS directory.
+
+Functions
+-----
+
+### topic path
+
+PureBuilder provides `DOC.mktopicpath` method.
+
+It returns `DOC.meta[:TopicPath]` (each document definition) *or* `DOC.pbenv[:TopicPath]`.
+
+It means you can define like `@config[:TopicPath] = [:Foo, :Bar]` for use automatic topic path.
+
+If you wrote it and define document title "Hello", `DOC.mktopicpath` returns
+
+ [ :Foo, :Bar, "Hello" ]
+
+or if you define `DOC.meta[:Index]` as `true`, then
+
+ [ :Foo, "Hello" ]
+
+If you want to define ACCS index as a index page,
+don't warry, automatic ACCS index *always* treat as a index page.
diff --git a/rubylib/purebuilder.rb b/rubylib/purebuilder.rb
index f4cc55a..438e30a 100644
--- a/rubylib/purebuilder.rb
+++ b/rubylib/purebuilder.rb
@@ -23,6 +23,30 @@ class <<DOC
self.meta["purebuilder_param"][:purebuilder_config]
end
+ def mktopicpath
+ # This make an Array of parent pathes Simbols added the String of article's title.
+ # If it is defined by DOC.meta[:TopicPath || "TopicPath"], then return it (for compatibility.)
+ # Otherwise, you can define @config[:TopicPath] in .purebuilderrc.rb or .accsrc.rb. This method returns it added the String of article's title unless DOC.meta[:Index || "Index"] is true.
+ # If DOC.meta[:Index || "Index"] is true, the article title replace last element of topic path.
+ if tp = ::DOC.meta[:TopicPath] || ::DOC.meta["TopicPath"]
+ # Defined in the document.
+ return tp.clone
+ elsif tp = ::DOC.pbenv[:TopicPath]
+ puts ::DOC
+ tp = tp.clone
+ # Index file?
+ if ::DOC.meta[:Index] || ::DOC.meta["Index"]
+ tp.pop
+ end
+
+ tp.push(::DOC.meta[:Title] || ::DOC.meta["Title"] || ::DOC.meta["title"] )
+ return tp
+ else
+ # No topic path.
+ [ ::DOC.meta[:Title] || ::DOC.meta["Title"] || ::DOC.meta["title"] ]
+ end
+ end
+
alias __extend extend
def extend(*mod)
@@ -485,6 +509,7 @@ class PureBuilder
::DOC.__setobj__( @config[:puredoc_class].new)
::DOC.meta = @config[:accs_indexmeta] || {}
::DOC.meta["last-update"] = Time.now.to_s
+ ::DOC.meta[:Index] = true
pbconf = get_pbconf
::DOC.meta["purebuilder_param"] = pbconf
indextemplate = File.read(@config[:accs_indextpl])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment