diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 20a509f8..b86d82b8 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -266,6 +266,11 @@ credits = [ '2012 Plataformatec', 'Apache', 'https://raw.githubusercontent.com/elixir-lang/elixir/master/LICENSE' + ], [ + 'Elisp', + '1990-1996, 1998-2019 Free Software Foundation, Inc.', + 'GPLv3', + 'https://www.gnu.org/licenses/gpl-3.0.html' ], [ 'Ember.js', '2017 Yehuda Katz, Tom Dale and Ember.js contributors', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 4a83095e..3f283cc0 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -53,6 +53,7 @@ 'pages/dojo', 'pages/drupal', 'pages/elixir', + 'pages/elisp', 'pages/ember', 'pages/erlang', 'pages/express', diff --git a/assets/stylesheets/pages/_elisp.scss b/assets/stylesheets/pages/_elisp.scss new file mode 100644 index 00000000..f8fbe580 --- /dev/null +++ b/assets/stylesheets/pages/_elisp.scss @@ -0,0 +1,14 @@ +._elisp { + dl > dt { + @extend %block-label, %label-blue; + } + + dl[compact] > dt { + background: none; + border-color: none; + line-height: normal; + margin: auto; + border: none; + } + +} diff --git a/lib/docs/filters/elisp/clean_html.rb b/lib/docs/filters/elisp/clean_html.rb new file mode 100644 index 00000000..7d173360 --- /dev/null +++ b/lib/docs/filters/elisp/clean_html.rb @@ -0,0 +1,66 @@ +module Docs + class Elisp + class CleanHtmlFilter < Filter + def call + + if current_url == root_url + # remove copyright header + css('table ~ p').remove + + # remove "Detailed Node Listing" header + css('h2').remove + + # remove "Detailed Node Listing" table + css('table')[1].remove + + # remove copyright + css('blockquote').remove + + # remove index page in the index table + css('tbody tr:last-child').remove + end + + # remove navigation bar + css('.header').remove + + # Remove content in headers + css('.chapter', '.section', '.subsection', '.subsubsection', '.appendix').each do |node| + + # remove numbers at the beginning of all headers + node.content = node.content.slice(/[[:alpha:]]...*/) + + # remove 'Appendix' word + node.content = node.content.sub(/Appendix.{2}/, '') if node.content.include?('Appendix') + + # remove 'E.' notation for appendixes + if node.content.match?(/[[:upper:]]\./) + # remove 'E.' + node.content = node.content.sub(/[[:upper:]]\./, '') + # remove all dots (.) + node.content = node.content.gsub(/\./, '') + # remove all numbers + node.content = node.content.gsub(/[[:digit:]]/, '') + end + + end + + # add id to each defun section that contains a functions, macro, etc. + css('dl > dt').each do |node| + if !(node.parent.attribute('compact')) + node['id'] = node.at_css('strong').content + end + end + + # remove br for style purposes + css('br').each do |node| + node.remove + end + + # remove footnotes + css('.footnote').remove + + doc + end + end + end +end diff --git a/lib/docs/filters/elisp/entries.rb b/lib/docs/filters/elisp/entries.rb new file mode 100644 index 00000000..9ccacb59 --- /dev/null +++ b/lib/docs/filters/elisp/entries.rb @@ -0,0 +1,52 @@ +module Docs + class Elisp + class EntriesFilter < Docs::EntriesFilter + def get_name + # remove numbers at the beginnig + name = at_css('.chapter', '.section', '.subsection', '.subsubsection', '.appendix').content.slice(/[[:alpha:]]...*/) + + # remove 'Appendix' word + name = name.sub(/Appendix.{2}/, '') if name.include?('Appendix') + + # remove 'E.' notation for appendixes + if name.match?(/[[:upper:]]\./) + # remove 'E.' + name = name.sub(/[[:upper:]]\./, '') + # remove all dots (.) + name = name.gsub(/\./, '') + # remove all numbers + name = name.gsub(/[[:digit:]]/, '') + end + + name + end + + def get_type + 'Manual' + end + + def additional_entries + entries = [] + + css('dl > dt').each do |node| + if !(node.parent.attribute('compact')) + entry_type = 'Builtin Functions' if node.content.include?('Function') + entry_type = 'Builtin Macros' if node.content.include?('Macro') + entry_type = 'Builtin Variables' if node.content.include?('Variable') + entry_type = 'Builtin User Options' if node.content.include?('User Option') + entry_type = 'Builtin Special Forms' if node.content.include?('Special Form') + entry_type = 'Builtin Commands' if node.content.include?('Command') + entry_type = 'Builtin Constants' if node.content.include?('Constant') + + entry_name = node.at_css('strong').content + entry_path = slug + '#' + entry_name + entries << [entry_name, entry_path.downcase, entry_type] + end + end + + entries + end + + end + end +end diff --git a/lib/docs/scrapers/elisp.rb b/lib/docs/scrapers/elisp.rb new file mode 100644 index 00000000..70702945 --- /dev/null +++ b/lib/docs/scrapers/elisp.rb @@ -0,0 +1,70 @@ +module Docs + class Elisp < UrlScraper + self.type = 'elisp' + self.release = '27.1' + self.base_url= 'https://www.gnu.org/software/emacs/manual/html_node/elisp/' + self.root_path = 'index.html' + self.links = { + home:'https://www.gnu.org/software/emacs/manual/elisp', + code: 'https://git.savannah.gnu.org/cgit/emacs.git' + } + + html_filters.push 'elisp/entries', 'elisp/clean_html' + + # some file that were not skipped by skip patterns + options[:skip] = [ + 'Coding-Conventions.html', + 'Key-Binding-Conventions.html', + 'Library-Headers.html' + ] + + # some non essential sections + options[:skip_patterns] = [ + /Introduction.html/, + /Antinews.html/, + /GNU-Free-Documentation-License.html/, + /GPL.html/, + /Tips.html/, + /Definition-of-/ + ] + + # fix duplicates + options[:fix_urls]= -> (url) do + url.sub!('Window-Group.html', 'Basic-Windows.html') + url.sub!('Local-defvar-example.html', 'Using-Lexical-Binding.html') + url.sub!('Defining-Lisp-variables-in-C.html', 'Writing-Emacs-Primitives.html') + url.sub!('describe_002dsymbols-example.html', 'Accessing-Documentation.html') + url.sub!('The-interactive_002donly-property.html', 'Defining-Commands.html') + url.sub!('Text-help_002decho.html', 'Special-Properties.html') + url.sub!('Help-display.html', 'Special-Properties.html') + url.sub!('autoload-cookie.html', 'Autoload.html') + url.sub!('external_002ddebugging_002doutput.html', 'Output-Streams.html') + url.sub!('modifier-bits.html', 'Other-Char-Bits.html') + url.sub!('message_002dbox.html', 'Displaying-Messages.html') + url.sub!('abbreviate_002dfile_002dname.html', 'Directory-Names.html') + url.sub!('Inhibit-point-motion-hooks.html', 'Special-Properties.html') + url.sub!('Coding-systems-for-a-subprocess.html', 'Process-Information.html') + url.sub!('Process-Filter-Example.html', 'Filter-Functions.html') + url.sub!('Docstring-hyperlinks.html', 'Documentation-Tips.html') + url.sub!('seq_002dlet.html', 'Sequence-Functions.html') + url.sub!('should_005fquit.html', 'Module-Misc.html') + url.sub!('Display-Face-Attribute-Testing.html', 'Display-Feature-Testing.html') + url.sub!('module-initialization-function.html', 'Module-Initialization.html') + url.sub!('pcase_002dsymbol_002dcaveats.html', 'pcase-Macro.html') + url.sub!('intern.html', 'Module-Misc.html') + url.sub!('pcase_002dexample_002d1.html', 'pcase-Macro.html') + url + end + + options[:attribution]= <<-HTML + Copyright © 1990-1996, 1998-2019 Free Software Foundation, Inc.
+ Licensed under the GNU GPL license. + HTML + + def get_latest_version(opts) + body = fetch('https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html', opts) + body.scan(/version \d*\.?\d*/)[0].sub('version', '') + end + + end +end diff --git a/public/icons/docs/elisp/16.png b/public/icons/docs/elisp/16.png new file mode 100644 index 00000000..dc2d8ca8 Binary files /dev/null and b/public/icons/docs/elisp/16.png differ diff --git a/public/icons/docs/elisp/16@2x.png b/public/icons/docs/elisp/16@2x.png new file mode 100644 index 00000000..e68bf718 Binary files /dev/null and b/public/icons/docs/elisp/16@2x.png differ diff --git a/public/icons/docs/elisp/SOURCE b/public/icons/docs/elisp/SOURCE new file mode 100644 index 00000000..6afbe82d --- /dev/null +++ b/public/icons/docs/elisp/SOURCE @@ -0,0 +1 @@ +https://www.gnu.org/software/emacs/