All commands without extension C-API. No fancy style or anything.
Unified · Split
| @@ -72,6 +72,7 @@ · 71 unmodified lines | |||
| 72 | 'pages/rust', | 72 | 'pages/rust', |
| 73 | 'pages/socketio', | 73 | 'pages/socketio', |
| 74 | 'pages/sphinx', | 74 | 'pages/sphinx', |
| 75 | 'pages/tcl_tk', | ||
| 75 | 'pages/underscore', | 76 | 'pages/underscore', |
| 76 | 'pages/vagrant', | 77 | 'pages/vagrant', |
| 77 | 'pages/vue', | 78 | 'pages/vue', |
| @@ -72,6 +72,7 @@ · 71 unmodified lines | |||
| 72 | 'pages/rust', | 72 | 'pages/rust', |
| 73 | 'pages/socketio', | 73 | 'pages/socketio', |
| 74 | 'pages/sphinx', | 74 | 'pages/sphinx', |
| 75 | 'pages/tcl_tk', | ||
| 75 | 'pages/underscore', | 76 | 'pages/underscore', |
| 76 | 'pages/vagrant', | 77 | 'pages/vagrant', |
| 77 | 'pages/vue', | 78 | 'pages/vue', |
| @@ -0,0 +1,19 @@ | |||
| 1 | ._tcl_tk { | ||
| 2 | /* make content listing more compact */ | ||
| 3 | .description { | ||
| 4 | margin: 0; | ||
| 5 | > dd { | ||
| 6 | margin: 0; | ||
| 7 | } | ||
| 8 | } | ||
| 9 | dl { | ||
| 10 | margin: 0; | ||
| 11 | } | ||
| 12 | .copy { | ||
| 13 | /* per page copyright */ | ||
| 14 | white-space: pre; | ||
| 15 | font-size: 80%; | ||
| 16 | border-top: 1px solid #6A6A6A; | ||
| 17 | margin-top: 2em; | ||
| 18 | } | ||
| 19 | } | ||
| @@ -0,0 +1,52 @@ | |||
| 1 | module Docs | ||
| 2 | class TclTk | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | # Page Title | ||
| 6 | css('h2').remove | ||
| 7 | # Navigation | ||
| 8 | css('h3:first-child').remove | ||
| 9 | # restore breaks in copyright | ||
| 10 | txt = at_css('div.copy').content | ||
| 11 | at_css('div.copy').content = txt.gsub! /.Copyright/, "\n\\0" | ||
| 12 | |||
| 13 | file = result[:path].split('/')[-1] | ||
| 14 | re = Regexp.new('^' + Regexp.escape(file) + '(#.*)$') | ||
| 15 | css('a[name]').each do |node| | ||
| 16 | if node['href'] then | ||
| 17 | # useless name | ||
| 18 | node.remove_attribute 'name' | ||
| 19 | # make fragments relativ | ||
| 20 | if node['href'].match re then | ||
| 21 | node['href'] = node['href'].sub re, '\\1' | ||
| 22 | end | ||
| 23 | else | ||
| 24 | # move name to id | ||
| 25 | node.parent['id'] = node['name'] | ||
| 26 | node.parent.content = node.content | ||
| 27 | end | ||
| 28 | end | ||
| 29 | |||
| 30 | # remove keywords headline | ||
| 31 | css('h3').each do |node| | ||
| 32 | if node.content == 'KEYWORDS' then | ||
| 33 | node.remove | ||
| 34 | end | ||
| 35 | end | ||
| 36 | # remove keywords links | ||
| 37 | css('a').each do |node| | ||
| 38 | attr = node.attribute('href') | ||
| 39 | if attr && attr.value.match(/\/Keywords\//) then | ||
| 40 | # the ',' | ||
| 41 | if node.next_sibling then | ||
| 42 | node.next_sibling.remove | ||
| 43 | end | ||
| 44 | node.remove | ||
| 45 | end | ||
| 46 | end | ||
| 47 | |||
| 48 | doc | ||
| 49 | end | ||
| 50 | end | ||
| 51 | end | ||
| 52 | end | ||
| @@ -0,0 +1,57 @@ | |||
| 1 | module Docs | ||
| 2 | class TclTk | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 4 | #def additional_entries | ||
| 5 | # type = nil | ||
| 6 | #end | ||
| 7 | |||
| 8 | def split_slug | ||
| 9 | slug.sub! /\.html?/, '' | ||
| 10 | return *slug.split('/') | ||
| 11 | end | ||
| 12 | |||
| 13 | TYPE_MAP = { | ||
| 14 | 'TclCmd' => 'Tcl', | ||
| 15 | 'TkCmd' => 'Tk', | ||
| 16 | 'ItclCmd' => 'incr', | ||
| 17 | 'SqliteCmd' => 'tdbc', | ||
| 18 | 'TdbcCmd' => 'tdbc', | ||
| 19 | 'TdbcmysqlCmd' => 'tdbc', | ||
| 20 | 'TdbcodbcCmd' => 'tdbc', | ||
| 21 | 'TdbcpostgresCmd' => 'tdbc', | ||
| 22 | 'TdbcsqliteCmd' => 'tdbc', | ||
| 23 | 'ThreadCmd' => 'Thread', | ||
| 24 | 'UserCmd' => 'App' | ||
| 25 | } | ||
| 26 | |||
| 27 | def get_type | ||
| 28 | type, name = split_slug | ||
| 29 | type = TYPE_MAP[type] || type | ||
| 30 | if name == 'contents' then | ||
| 31 | type = nil | ||
| 32 | end | ||
| 33 | type | ||
| 34 | end | ||
| 35 | |||
| 36 | def get_name | ||
| 37 | type, name = split_slug | ||
| 38 | name | ||
| 39 | end | ||
| 40 | |||
| 41 | def additional_entries | ||
| 42 | type, name = split_slug | ||
| 43 | if type != 'TclCmd' || name != 'library' then | ||
| 44 | return [] | ||
| 45 | end | ||
| 46 | # special rule for library page which contains multiple commands at once | ||
| 47 | entries = [] | ||
| 48 | css('a > b').each do |node| | ||
| 49 | text = node.content.strip | ||
| 50 | id = node.parent['href'].sub /^.*#(.*)$/, '\\1' | ||
| 51 | entries << [text, id, TYPE_MAP[type]] | ||
| 52 | end | ||
| 53 | return entries | ||
| 54 | end | ||
| 55 | end | ||
| 56 | end | ||
| 57 | end | ||
| @@ -0,0 +1,42 @@ | |||
| 1 | module Docs | ||
| 2 | class TclTk < UrlScraper | ||
| 3 | self.name = 'Tcl/Tk' | ||
| 4 | self.type = 'tcl_tk' | ||
| 5 | self.slug = 'tcl' | ||
| 6 | self.version = '8.6' | ||
| 7 | # test URL: | ||
| 8 | self.base_url = 'http://localhost/tcl/' | ||
| 9 | # real URL: | ||
| 10 | #self.base_url = 'http://www.tcl.tk/man/tcl/' | ||
| 11 | self.root_path = 'contents.htm' | ||
| 12 | |||
| 13 | html_filters.push 'tcl_tk/clean_html', 'tcl_tk/entries' | ||
| 14 | |||
| 15 | options[:skip_links] = false | ||
| 16 | |||
| 17 | options[:trailing_slash] = false | ||
| 18 | options[:skip] = ['siteinfo.htm'] | ||
| 19 | options[:skip_patterns] = [ | ||
| 20 | # ignore keyword list pages | ||
| 21 | /^Keywords\//, | ||
| 22 | # ignore C-API, only required for extension developers | ||
| 23 | /^TclLib\//, | ||
| 24 | /^TkLib\//, | ||
| 25 | /^ItclLib\//, | ||
| 26 | /^TdbcLib\// | ||
| 27 | ] | ||
| 28 | |||
| 29 | # TODO can't figure out howto convert .htm => .html in filenames | ||
| 30 | # to save as "xyz.html" instead of "xyz.htm.html" | ||
| 31 | #options[:fix_urls] = ->(url) do | ||
| 32 | # url.sub! /\.htm($|#)/, '.html\\1' | ||
| 33 | # url | ||
| 34 | #end | ||
| 35 | |||
| 36 | # Each Page contains a specific list of copyrights, only add the | ||
| 37 | # overall license link | ||
| 38 | options[:attribution] = <<-HTML | ||
| 39 | Licensed under <a href="http://tcl.tk/software/tcltk/license.html">Tcl/Tk Terms</a> | ||
| 40 | HTML | ||
| 41 | end | ||
| 42 | end | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | |||
| 1 | https://commons.wikimedia.org/wiki/File:Tcl.svg | ||