Skip to content

Commit 0f9111b

Browse files
committed
Update Elisp documentation (31.1.50)
1 parent 4b33c8c commit 0f9111b

4 files changed

Lines changed: 51 additions & 91 deletions

File tree

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
@use 'global/classes';
22

33
._elisp {
4-
dl > dt {
4+
// definitions (@deffn, @defvr, ...) — the items of a plain @table have no class
5+
dl > dt[class] {
56
@extend %block-label, %label-blue;
67
}
7-
8-
dl[compact] > dt {
9-
background: none;
10-
border-color: none;
11-
line-height: normal;
12-
margin: auto;
13-
border: none;
14-
}
15-
168
}

‎lib/docs/filters/elisp/clean_html.rb‎

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ class CleanHtmlFilter < Filter
44
def call
55

66
if current_url == root_url
7-
# remove copyright header
8-
css('table ~ p').remove
7+
# remove the links to the Emacs website and the copyright notice
8+
css('#content > p').remove
99

10-
# remove "Detailed Node Listing" header
11-
css('h2').remove
12-
13-
# remove "Detailed Node Listing" table
14-
css('table')[1].remove
15-
16-
# remove copyright
10+
# remove the license
1711
css('blockquote').remove
1812

19-
# remove index page in the index table
20-
css('tbody tr:last-child').remove
13+
# remove the short table of contents, the detailed one follows it
14+
css('.element-shortcontents').remove
15+
16+
# remove "Table of Contents" header
17+
css('.contents-heading').remove
2118
end
2219

23-
# remove navigation bar
24-
css('.header').remove
20+
# remove navigation bars and their separators
21+
css('.nav-panel', 'hr').remove
22+
23+
# remove the "¶" links pointing at headers and definitions
24+
css('.copiable-link').remove
2525

2626
# Remove content in headers
2727
css('.chapter', '.section', '.subsection', '.subsubsection', '.appendix').each do |node|
@@ -44,11 +44,17 @@ def call
4444

4545
end
4646

47-
# add id to each defun section that contains a functions, macro, etc.
47+
# add a readable id to each definition of a function, macro, etc.
48+
# (the items of a plain @table have no name)
49+
ids = Hash.new(0)
4850
css('dl > dt').each do |node|
49-
if !(node.parent.attribute('compact'))
50-
node['id'] = node.at_css('strong').content
51-
end
51+
name = node.at_css('.def-name')
52+
next unless name
53+
54+
id = name.content
55+
# a few names are defined twice on the same page, e.g. as a function and as a variable
56+
count = ids[id] += 1
57+
node['id'] = count > 1 ? "#{id}-#{count}" : id
5258
end
5359

5460
# remove br for style purposes
@@ -57,7 +63,7 @@ def call
5763
end
5864

5965
# remove footnotes
60-
css('.footnote').remove
66+
css('.footnote', '.footnotes-segment').remove
6167

6268
doc
6369
end

‎lib/docs/filters/elisp/entries.rb‎

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
module Docs
22
class Elisp
33
class EntriesFilter < Docs::EntriesFilter
4-
def get_name
5-
# remove numbers at the beginning
6-
name = at_css('.chapter', '.section', '.subsection', '.subsubsection', '.appendix').content.slice(/[[:alpha:]]...*/)
7-
8-
# remove 'Appendix' word
9-
name = name.sub(/Appendix.{2}/, '') if name.include?('Appendix')
4+
TYPES = {
5+
'Function' => 'Builtin Functions',
6+
'Predicate' => 'Builtin Functions',
7+
'Macro' => 'Builtin Macros',
8+
'Variable' => 'Builtin Variables',
9+
'User Option' => 'Builtin User Options',
10+
'Special Form' => 'Builtin Special Forms',
11+
'Command' => 'Builtin Commands',
12+
'Prefix Command' => 'Builtin Commands',
13+
'Constant' => 'Builtin Constants'
14+
}
1015

11-
# remove 'E.' notation for appendixes
12-
if name.match?(/[[:upper:]]\./)
13-
# remove 'E.'
14-
name = name.sub(/[[:upper:]]\./, '')
15-
# remove all dots (.)
16-
name = name.gsub(/\./, '')
17-
# remove all numbers
18-
name = name.gsub(/[[:digit:]]/, '')
19-
end
20-
21-
name
16+
def get_name
17+
# the CleanHtmlFilter already removed the numbering from the headers
18+
at_css('.chapter', '.section', '.subsection', '.subsubsection', '.appendix').content
2219
end
2320

2421
def get_type
@@ -29,19 +26,13 @@ def additional_entries
2926
entries = []
3027

3128
css('dl > dt').each do |node|
32-
if !(node.parent.attribute('compact'))
33-
entry_type = 'Builtin Functions' if node.content.include?('Function')
34-
entry_type = 'Builtin Macros' if node.content.include?('Macro')
35-
entry_type = 'Builtin Variables' if node.content.include?('Variable')
36-
entry_type = 'Builtin User Options' if node.content.include?('User Option')
37-
entry_type = 'Builtin Special Forms' if node.content.include?('Special Form')
38-
entry_type = 'Builtin Commands' if node.content.include?('Command')
39-
entry_type = 'Builtin Constants' if node.content.include?('Constant')
29+
name = node.at_css('.def-name')
30+
next unless name
4031

41-
entry_name = node.at_css('strong').content
42-
entry_path = slug + '#' + entry_name
43-
entries << [entry_name, entry_path.downcase, entry_type]
44-
end
32+
category = node.at_css('.category-def')
33+
entry_type = TYPES[category.content.strip.chomp(':')] if category
34+
# the CleanHtmlFilter turned the name into the id of the definition
35+
entries << [name.content, node['id'], entry_type]
4536
end
4637

4738
entries

‎lib/docs/scrapers/elisp.rb‎

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module Docs
22
class Elisp < FileScraper
33
self.type = 'elisp'
4-
self.release = '28.2'
4+
self.release = '31.1.50'
55
self.base_url= 'https://www.gnu.org/software/emacs/manual/html_node/elisp/'
66
self.root_path = 'index.html'
77
self.links = {
88
home:'https://www.gnu.org/software/emacs/manual/elisp',
99
code: 'https://git.savannah.gnu.org/cgit/emacs.git'
1010
}
1111

12-
html_filters.push 'elisp/entries', 'elisp/clean_html'
12+
html_filters.push 'elisp/clean_html', 'elisp/entries'
1313

1414
# some file that were not skipped by skip patterns
1515
options[:skip] = [
@@ -24,46 +24,17 @@ class Elisp < FileScraper
2424
/Antinews.html/,
2525
/GNU-Free-Documentation-License.html/,
2626
/GPL.html/,
27-
/Tips.html/,
28-
/Definition-of-/
27+
/Tips.html/
2928
]
3029

31-
# fix duplicates
32-
options[:fix_urls]= -> (url) do
33-
url.sub!('Window-Group.html', 'Basic-Windows.html')
34-
url.sub!('Local-defvar-example.html', 'Using-Lexical-Binding.html')
35-
url.sub!('Defining-Lisp-variables-in-C.html', 'Writing-Emacs-Primitives.html')
36-
url.sub!('describe_002dsymbols-example.html', 'Accessing-Documentation.html')
37-
url.sub!('The-interactive_002donly-property.html', 'Defining-Commands.html')
38-
url.sub!('Text-help_002decho.html', 'Special-Properties.html')
39-
url.sub!('Help-display.html', 'Special-Properties.html')
40-
url.sub!('autoload-cookie.html', 'Autoload.html')
41-
url.sub!('external_002ddebugging_002doutput.html', 'Output-Streams.html')
42-
url.sub!('modifier-bits.html', 'Other-Char-Bits.html')
43-
url.sub!('message_002dbox.html', 'Displaying-Messages.html')
44-
url.sub!('abbreviate_002dfile_002dname.html', 'Directory-Names.html')
45-
url.sub!('Inhibit-point-motion-hooks.html', 'Special-Properties.html')
46-
url.sub!('Coding-systems-for-a-subprocess.html', 'Process-Information.html')
47-
url.sub!('Process-Filter-Example.html', 'Filter-Functions.html')
48-
url.sub!('Docstring-hyperlinks.html', 'Documentation-Tips.html')
49-
url.sub!('seq_002dlet.html', 'Sequence-Functions.html')
50-
url.sub!('should_005fquit.html', 'Module-Misc.html')
51-
url.sub!('Display-Face-Attribute-Testing.html', 'Display-Feature-Testing.html')
52-
url.sub!('module-initialization-function.html', 'Module-Initialization.html')
53-
url.sub!('pcase_002dsymbol_002dcaveats.html', 'pcase-Macro.html')
54-
url.sub!('intern.html', 'Module-Misc.html')
55-
url.sub!('pcase_002dexample_002d1.html', 'pcase-Macro.html')
56-
url
57-
end
58-
5930
options[:attribution]= <<-HTML
60-
Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>
31+
Copyright &copy; 1990-1996, 1998-2026 Free Software Foundation, Inc. <br>
6132
Licensed under the GNU GPL license.
6233
HTML
6334

6435
def get_latest_version(opts)
6536
body = fetch('https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html', opts)
66-
body.scan(/version \d*\.?\d*/)[0].sub('version', '')
37+
body.scan(/version \d+(?:\.\d+)*/)[0].sub('version ', '')
6738
end
6839

6940
private

0 commit comments

Comments
 (0)