Add Tcl/Tk documentation

All commands without extension C-API. No fancy style or anything.
This commit is contained in:
Tobias 2015-11-17 21:30:00 +01:00 committed by Thibaut Courouble
parent a24a2ce1fe
commit ae7a5abd96
9 changed files with 173 additions and 0 deletions

View file

@ -72,6 +72,7 @@
'pages/rust',
'pages/socketio',
'pages/sphinx',
'pages/tcl_tk',
'pages/underscore',
'pages/vagrant',
'pages/vue',

View file

@ -72,6 +72,7 @@
'pages/rust',
'pages/socketio',
'pages/sphinx',
'pages/tcl_tk',
'pages/underscore',
'pages/vagrant',
'pages/vue',

View file

@ -0,0 +1,19 @@
._tcl_tk {
/* make content listing more compact */
.description {
margin: 0;
> dd {
margin: 0;
}
}
dl {
margin: 0;
}
.copy {
/* per page copyright */
white-space: pre;
font-size: 80%;
border-top: 1px solid #6A6A6A;
margin-top: 2em;
}
}

View file

@ -0,0 +1,52 @@
module Docs
class TclTk
class CleanHtmlFilter < Filter
def call
# Page Title
css('h2').remove
# Navigation
css('h3:first-child').remove
# restore breaks in copyright
txt = at_css('div.copy').content
at_css('div.copy').content = txt.gsub! /.Copyright/, "\n\\0"
file = result[:path].split('/')[-1]
re = Regexp.new('^' + Regexp.escape(file) + '(#.*)$')
css('a[name]').each do |node|
if node['href'] then
# useless name
node.remove_attribute 'name'
# make fragments relativ
if node['href'].match re then
node['href'] = node['href'].sub re, '\\1'
end
else
# move name to id
node.parent['id'] = node['name']
node.parent.content = node.content
end
end
# remove keywords headline
css('h3').each do |node|
if node.content == 'KEYWORDS' then
node.remove
end
end
# remove keywords links
css('a').each do |node|
attr = node.attribute('href')
if attr && attr.value.match(/\/Keywords\//) then
# the ','
if node.next_sibling then
node.next_sibling.remove
end
node.remove
end
end
doc
end
end
end
end

View file

@ -0,0 +1,57 @@
module Docs
class TclTk
class EntriesFilter < Docs::EntriesFilter
#def additional_entries
# type = nil
#end
def split_slug
slug.sub! /\.html?/, ''
return *slug.split('/')
end
TYPE_MAP = {
'TclCmd' => 'Tcl',
'TkCmd' => 'Tk',
'ItclCmd' => 'incr',
'SqliteCmd' => 'tdbc',
'TdbcCmd' => 'tdbc',
'TdbcmysqlCmd' => 'tdbc',
'TdbcodbcCmd' => 'tdbc',
'TdbcpostgresCmd' => 'tdbc',
'TdbcsqliteCmd' => 'tdbc',
'ThreadCmd' => 'Thread',
'UserCmd' => 'App'
}
def get_type
type, name = split_slug
type = TYPE_MAP[type] || type
if name == 'contents' then
type = nil
end
type
end
def get_name
type, name = split_slug
name
end
def additional_entries
type, name = split_slug
if type != 'TclCmd' || name != 'library' then
return []
end
# special rule for library page which contains multiple commands at once
entries = []
css('a > b').each do |node|
text = node.content.strip
id = node.parent['href'].sub /^.*#(.*)$/, '\\1'
entries << [text, id, TYPE_MAP[type]]
end
return entries
end
end
end
end

View file

@ -0,0 +1,42 @@
module Docs
class TclTk < UrlScraper
self.name = 'Tcl/Tk'
self.type = 'tcl_tk'
self.slug = 'tcl'
self.version = '8.6'
# test URL:
self.base_url = 'http://localhost/tcl/'
# real URL:
#self.base_url = 'http://www.tcl.tk/man/tcl/'
self.root_path = 'contents.htm'
html_filters.push 'tcl_tk/clean_html', 'tcl_tk/entries'
options[:skip_links] = false
options[:trailing_slash] = false
options[:skip] = ['siteinfo.htm']
options[:skip_patterns] = [
# ignore keyword list pages
/^Keywords\//,
# ignore C-API, only required for extension developers
/^TclLib\//,
/^TkLib\//,
/^ItclLib\//,
/^TdbcLib\//
]
# TODO can't figure out howto convert .htm => .html in filenames
# to save as "xyz.html" instead of "xyz.htm.html"
#options[:fix_urls] = ->(url) do
# url.sub! /\.htm($|#)/, '.html\\1'
# url
#end
# Each Page contains a specific list of copyrights, only add the
# overall license link
options[:attribution] = <<-HTML
Licensed under <a href="http://tcl.tk/software/tcltk/license.html">Tcl/Tk Terms</a>
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

View file

@ -0,0 +1 @@
https://commons.wikimedia.org/wiki/File:Tcl.svg