diff --git a/Gemfile b/Gemfile index 7227e7605e..4eed883182 100644 --- a/Gemfile +++ b/Gemfile @@ -42,4 +42,7 @@ group :development do gem 'ostruct' gem 'reline' + gem 'nokogiri' + + gem 'svn-downloader' end diff --git a/lib/rouge/lexers/apache.rb b/lib/rouge/lexers/apache.rb index 57de58c11b..50b42683f6 100644 --- a/lib/rouge/lexers/apache.rb +++ b/lib/rouge/lexers/apache.rb @@ -17,6 +17,8 @@ class Apache < RegexLexer end def name_for_token(token, tktype) + token = token.downcase + if SECTIONS.include? token tktype elsif DIRECTIVES.include? token @@ -37,12 +39,12 @@ def name_for_token(token, tktype) mixin :whitespace rule %r/(<\/?)(\w+)/ do |m| - groups Punctuation, name_for_token(m[2].downcase, Name::Label) + groups Punctuation, name_for_token(m[2], Name::Label) push :section end rule %r/\w+/ do |m| - token name_for_token(m[0].downcase, Name::Class) + token name_for_token(m[0], Name::Class) push :directive end end @@ -64,8 +66,22 @@ def name_for_token(token, tktype) mixin :whitespace rule %r/\S+/ do |m| - token name_for_token(m[0].downcase, Literal::String::Symbol) + if VALUES.include?(m[0].downcase) + token Literal::String::Symbol + else + fallthrough! + end end + + rule(%r/(?=\S)/) { push :value } + end + + state :value do + rule %r/[ \t]+/, Text, :pop! + rule %r/[^\s%]+/, Text + rule %r/%{.*?}/, Name::Variable + rule %r/[%]/, Text + rule(/(?=\n)/) { pop! } end end end diff --git a/lib/rouge/lexers/apache/keywords.rb b/lib/rouge/lexers/apache/keywords.rb index f25445cb6f..afaa22d9f8 100644 --- a/lib/rouge/lexers/apache/keywords.rb +++ b/lib/rouge/lexers/apache/keywords.rb @@ -8,11 +8,9 @@ module Rouge module Lexers class Apache - DIRECTIVES = Set["acceptfilter", "acceptpathinfo", "accessfilename", "action", "addalt", "addaltbyencoding", "addaltbytype", "addcharset", "adddefaultcharset", "adddescription", "addencoding", "addhandler", "addicon", "addiconbyencoding", "addiconbytype", "addinputfilter", "addlanguage", "addmoduleinfo", "addoutputfilter", "addoutputfilterbytype", "addtype", "alias", "aliasmatch", "allow", "allowconnect", "allowencodedslashes", "allowmethods", "allowoverride", "allowoverridelist", "anonymous", "anonymous_logemail", "anonymous_mustgiveemail", "anonymous_nouserid", "anonymous_verifyemail", "asyncrequestworkerfactor", "authbasicauthoritative", "authbasicfake", "authbasicprovider", "authbasicusedigestalgorithm", "authdbduserpwquery", "authdbduserrealmquery", "authdbmgroupfile", "authdbmtype", "authdbmuserfile", "authdigestalgorithm", "authdigestdomain", "authdigestnoncelifetime", "authdigestprovider", "authdigestqop", "authdigestshmemsize", "authformauthoritative", "authformbody", "authformdisablenostore", "authformfakebasicauth", "authformlocation", "authformloginrequiredlocation", "authformloginsuccesslocation", "authformlogoutlocation", "authformmethod", "authformmimetype", "authformpassword", "authformprovider", "authformsitepassphrase", "authformsize", "authformusername", "authgroupfile", "authldapauthorizeprefix", "authldapbindauthoritative", "authldapbinddn", "authldapbindpassword", "authldapcharsetconfig", "authldapcompareasuser", "authldapcomparednonserver", "authldapdereferencealiases", "authldapgroupattribute", "authldapgroupattributeisdn", "authldapinitialbindasuser", "authldapinitialbindpattern", "authldapmaxsubgroupdepth", "authldapremoteuserattribute", "authldapremoteuserisdn", "authldapsearchasuser", "authldapsubgroupattribute", "authldapsubgroupclass", "authldapurl", "authmerging", "authname", "authncachecontext", "authncacheenable", "authncacheprovidefor", "authncachesocache", "authncachetimeout", "authnzfcgicheckauthnprovider", "authnzfcgidefineprovider", "authtype", "authuserfile", "authzdbdlogintoreferer", "authzdbdquery", "authzdbdredirectquery", "authzdbmtype", "authzsendforbiddenonfailure", "balancergrowth", "balancerinherit", "balancermember", "balancerpersist", "brotlialteretag", "brotlicompressionmaxinputblock", "brotlicompressionquality", "brotlicompressionwindow", "brotlifilternote", "browsermatch", "browsermatchnocase", "bufferedlogs", "buffersize", "cachedefaultexpire", "cachedetailheader", "cachedirlength", "cachedirlevels", "cachedisable", "cacheenable", "cachefile", "cacheheader", "cacheignorecachecontrol", "cacheignoreheaders", "cacheignorenolastmod", "cacheignorequerystring", "cacheignoreurlsessionidentifiers", "cachekeybaseurl", "cachelastmodifiedfactor", "cachelock", "cachelockmaxage", "cachelockpath", "cachemaxexpire", "cachemaxfilesize", "cacheminexpire", "cacheminfilesize", "cachenegotiateddocs", "cachequickhandler", "cachereadsize", "cachereadtime", "cacheroot", "cachesocache", "cachesocachemaxsize", "cachesocachemaxtime", "cachesocachemintime", "cachesocachereadsize", "cachesocachereadtime", "cachestaleonerror", "cachestoreexpired", "cachestorenostore", "cachestoreprivate", "cgidscripttimeout", "cgimapextension", "cgipassauth", "cgivar", "charsetdefault", "charsetoptions", "charsetsourceenc", "checkcaseonly", "checkspelling", "chrootdir", "contentdigest", "cookiedomain", "cookieexpires", "cookiename", "cookiestyle", "cookietracking", "coredumpdirectory", "customlog", "dav", "davdepthinfinity", "davgenericlockdb", "davlockdb", "davmintimeout", "dbdexptime", "dbdinitsql", "dbdkeep", "dbdmax", "dbdmin", "dbdparams", "dbdpersist", "dbdpreparesql", "dbdriver", "defaulticon", "defaultlanguage", "defaultruntimedir", "defaulttype", "define", "deflatebuffersize", "deflatecompressionlevel", "deflatefilternote", "deflateinflatelimitrequestbody", "deflateinflateratioburst", "deflateinflateratiolimit", "deflatememlevel", "deflatewindowsize", "deny", "directorycheckhandler", "directoryindex", "directoryindexredirect", "directoryslash", "documentroot", "dtraceprivileges", "dumpioinput", "dumpiooutput", "enableexceptionhook", "enablemmap", "enablesendfile", "error", "errordocument", "errorlog", "errorlogformat", "example", "expiresactive", "expiresbytype", "expiresdefault", "extendedstatus", "extfilterdefine", "extfilteroptions", "fallbackresource", "fileetag", "filterchain", "filterdeclare", "filterprotocol", "filterprovider", "filtertrace", "forcelanguagepriority", "forcetype", "forensiclog", "globallog", "gprofdir", "gracefulshutdowntimeout", "group", "h2copyfiles", "h2direct", "h2earlyhints", "h2maxsessionstreams", "h2maxworkeridleseconds", "h2maxworkers", "h2minworkers", "h2moderntlsonly", "h2push", "h2pushdiarysize", "h2pushpriority", "h2pushresource", "h2serializeheaders", "h2streammaxmemsize", "h2tlscooldownsecs", "h2tlswarmupsize", "h2upgrade", "h2windowsize", "header", "headername", "heartbeataddress", "heartbeatlisten", "heartbeatmaxservers", "heartbeatstorage", "heartbeatstorage", "hostnamelookups", "httpprotocoloptions", "identitycheck", "identitychecktimeout", "imapbase", "imapdefault", "imapmenu", "include", "includeoptional", "indexheadinsert", "indexignore", "indexignorereset", "indexoptions", "indexorderdefault", "indexstylesheet", "inputsed", "isapiappendlogtoerrors", "isapiappendlogtoquery", "isapicachefile", "isapifakeasync", "isapilognotsupported", "isapireadaheadbuffer", "keepalive", "keepalivetimeout", "keptbodysize", "languagepriority", "ldapcacheentries", "ldapcachettl", "ldapconnectionpoolttl", "ldapconnectiontimeout", "ldaplibrarydebug", "ldapopcacheentries", "ldapopcachettl", "ldapreferralhoplimit", "ldapreferrals", "ldapretries", "ldapretrydelay", "ldapsharedcachefile", "ldapsharedcachesize", "ldaptimeout", "ldaptrustedclientcert", "ldaptrustedglobalcert", "ldaptrustedmode", "ldapverifyservercert", "limitinternalrecursion", "limitrequestbody", "limitrequestfields", "limitrequestfieldsize", "limitrequestline", "limitxmlrequestbody", "listen", "listenbacklog", "listencoresbucketsratio", "loadfile", "loadmodule", "logformat", "logiotrackttfb", "loglevel", "logmessage", "luaauthzprovider", "luacodecache", "luahookaccesschecker", "luahookauthchecker", "luahookcheckuserid", "luahookfixups", "luahookinsertfilter", "luahooklog", "luahookmaptostorage", "luahooktranslatename", "luahooktypechecker", "luainherit", "luainputfilter", "luamaphandler", "luaoutputfilter", "luapackagecpath", "luapackagepath", "luaquickhandler", "luaroot", "luascope", "maxconnectionsperchild", "maxkeepaliverequests", "maxmemfree", "maxrangeoverlaps", "maxrangereversals", "maxranges", "maxrequestworkers", "maxspareservers", "maxsparethreads", "maxthreads", "mdbaseserver", "mdcachallenges", "mdcertificateagreement", "mdcertificateauthority", "mdcertificateprotocol", "mddrivemode", "mdhttpproxy", "mdmember", "mdmembers", "mdmuststaple", "mdnotifycmd", "mdomain", "mdportmap", "mdprivatekeys", "mdrenewwindow", "mdrequirehttps", "mdstoredir", "memcacheconnttl", "mergetrailers", "metadir", "metafiles", "metasuffix", "mimemagicfile", "minspareservers", "minsparethreads", "mmapfile", "modemstandard", "modmimeusepathinfo", "multiviewsmatch", "mutex", "namevirtualhost", "noproxy", "nwssltrustedcerts", "nwsslupgradeable", "options", "order", "outputsed", "passenv", "pidfile", "privilegesmode", "protocol", "protocolecho", "protocols", "protocolshonororder", "proxyaddheaders", "proxybadheader", "proxyblock", "proxydomain", "proxyerroroverride", "proxyexpressdbmfile", "proxyexpressdbmtype", "proxyexpressenable", "proxyfcgibackendtype", "proxyfcgisetenvif", "proxyftpdircharset", "proxyftpescapewildcards", "proxyftplistonwildcard", "proxyhcexpr", "proxyhctemplate", "proxyhctpsize", "proxyhtmlbufsize", "proxyhtmlcharsetout", "proxyhtmldoctype", "proxyhtmlenable", "proxyhtmlevents", "proxyhtmlextended", "proxyhtmlfixups", "proxyhtmlinterp", "proxyhtmllinks", "proxyhtmlmeta", "proxyhtmlstripcomments", "proxyhtmlurlmap", "proxyiobuffersize", "proxymaxforwards", "proxypass", "proxypassinherit", "proxypassinterpolateenv", "proxypassmatch", "proxypassreverse", "proxypassreversecookiedomain", "proxypassreversecookiepath", "proxypreservehost", "proxyreceivebuffersize", "proxyremote", "proxyremotematch", "proxyrequests", "proxyscgiinternalredirect", "proxyscgisendfile", "proxyset", "proxysourceaddress", "proxystatus", "proxytimeout", "proxyvia", "qualifyredirecturl", "readmename", "receivebuffersize", "redirect", "redirectmatch", "redirectpermanent", "redirecttemp", "reflectorheader", "registerhttpmethod", "remoteipheader", "remoteipinternalproxy", "remoteipinternalproxylist", "remoteipproxiesheader", "remoteipproxyprotocol", "remoteipproxyprotocolexceptions", "remoteiptrustedproxy", "remoteiptrustedproxylist", "removecharset", "removeencoding", "removehandler", "removeinputfilter", "removelanguage", "removeoutputfilter", "removetype", "requestheader", "requestreadtimeout", "require", "rewritebase", "rewritecond", "rewriteengine", "rewritemap", "rewriteoptions", "rewriterule", "rlimitcpu", "rlimitmem", "rlimitnproc", "satisfy", "scoreboardfile", "script", "scriptalias", "scriptaliasmatch", "scriptinterpretersource", "scriptlog", "scriptlogbuffer", "scriptloglength", "scriptsock", "securelisten", "seerequesttail", "sendbuffersize", "serveradmin", "serveralias", "serverlimit", "servername", "serverpath", "serverroot", "serversignature", "servertokens", "session", "sessioncookiename", "sessioncookiename2", "sessioncookieremove", "sessioncryptocipher", "sessioncryptodriver", "sessioncryptopassphrase", "sessioncryptopassphrasefile", "sessiondbdcookiename", "sessiondbdcookiename2", "sessiondbdcookieremove", "sessiondbddeletelabel", "sessiondbdinsertlabel", "sessiondbdperuser", "sessiondbdselectlabel", "sessiondbdupdatelabel", "sessionenv", "sessionexclude", "sessionheader", "sessioninclude", "sessionmaxage", "setenv", "setenvif", "setenvifexpr", "setenvifnocase", "sethandler", "setinputfilter", "setoutputfilter", "ssiendtag", "ssierrormsg", "ssietag", "ssilastmodified", "ssilegacyexprparser", "ssistarttag", "ssitimeformat", "ssiundefinedecho", "sslcacertificatefile", "sslcacertificatepath", "sslcadnrequestfile", "sslcadnrequestpath", "sslcarevocationcheck", "sslcarevocationfile", "sslcarevocationpath", "sslcertificatechainfile", "sslcertificatefile", "sslcertificatekeyfile", "sslciphersuite", "sslcompression", "sslcryptodevice", "sslengine", "sslfips", "sslhonorcipherorder", "sslinsecurerenegotiation", "sslocspdefaultresponder", "sslocspenable", "sslocspnoverify", "sslocspoverrideresponder", "sslocspproxyurl", "sslocsprespondercertificatefile", "sslocsprespondertimeout", "sslocspresponsemaxage", "sslocspresponsetimeskew", "sslocspuserequestnonce", "sslopensslconfcmd", "ssloptions", "sslpassphrasedialog", "sslprotocol", "sslproxycacertificatefile", "sslproxycacertificatepath", "sslproxycarevocationcheck", "sslproxycarevocationfile", "sslproxycarevocationpath", "sslproxycheckpeercn", "sslproxycheckpeerexpire", "sslproxycheckpeername", "sslproxyciphersuite", "sslproxyengine", "sslproxymachinecertificatechainfile", "sslproxymachinecertificatefile", "sslproxymachinecertificatepath", "sslproxyprotocol", "sslproxyverify", "sslproxyverifydepth", "sslrandomseed", "sslrenegbuffersize", "sslrequire", "sslrequiressl", "sslsessioncache", "sslsessioncachetimeout", "sslsessionticketkeyfile", "sslsessiontickets", "sslsrpunknownuserseed", "sslsrpverifierfile", "sslstaplingcache", "sslstaplingerrorcachetimeout", "sslstaplingfaketrylater", "sslstaplingforceurl", "sslstaplingrespondertimeout", "sslstaplingresponsemaxage", "sslstaplingresponsetimeskew", "sslstaplingreturnrespondererrors", "sslstaplingstandardcachetimeout", "sslstrictsnivhostcheck", "sslusername", "sslusestapling", "sslverifyclient", "sslverifydepth", "startservers", "startthreads", "substitute", "substituteinheritbefore", "substitutemaxlinelength", "suexec", "suexecusergroup", "threadlimit", "threadsperchild", "threadstacksize", "timeout", "traceenable", "transferlog", "typesconfig", "undefine", "undefmacro", "unsetenv", "use", "usecanonicalname", "usecanonicalphysicalport", "user", "userdir", "vhostcgimode", "vhostcgiprivs", "vhostgroup", "vhostprivs", "vhostsecure", "vhostuser", "virtualdocumentroot", "virtualdocumentrootip", "virtualscriptalias", "virtualscriptaliasip", "watchdoginterval", "xbithack", "xml2encalias", "xml2encdefault", "xml2startparse"] - - SECTIONS = Set["authnprovideralias", "authzprovideralias", "directory", "directorymatch", "else", "elseif", "files", "filesmatch", "if", "ifdefine", "ifmodule", "ifversion", "limit", "limitexcept", "location", "locationmatch", "macro", "mdomainset", "proxy", "proxymatch", "requireall", "requireany", "requirenone", "virtualhost"] - - VALUES = Set["add", "addaltclass", "addsuffix", "alias", "all", "allow", "allowanyuri", "allownoslash", "always", "and", "any", "ap_auth_internal_per_uri", "api_version", "append", "ascending", "attribute", "auth", "auth-int", "authconfig", "auto", "backend-address", "balancer_name", "balancer_route_changed", "balancer_session_route", "balancer_session_sticky", "balancer_worker_name", "balancer_worker_route", "base", "basedn", "basic", "before", "block", "boolean", "byte", "byteranges", "cache", "cache-hit", "cache-invalidate", "cache-miss", "cache-revalidate", "cgi", "chain", "change", "charset", "circle", "cmd", "conditional-expression", "condpattern", "conn", "conn_remote_addr", "cookie", "cookie2", "current-uri", "date", "date_gmt", "date_local", "db", "dbm", "decoding", "default", "deny", "descending", "description", "descriptionwidth", "digest", "disabled", "disableenv", "dns", "document_args", "document_name", "document_root", "document_uri", "domain", "double", "duration", "early", "echo", "echomsg", "edit", "edit*", "email", "enableenv", "encoding", "env", "environment-variable-name", "errmsg", "error", "errorlog", "errorlogformat", "execcgi", "expr", "fallback", "fancyindexing", "fast", "file", "file-group", "file-owner", "fileinfo", "filename", "filter", "filter-name", "filter_name", "filters", "finding", "first-dot", "foldersfirst", "followsymlinks", "forever", "form", "formatted", "fpm", "from", "ftype", "full", "function_name", "gdbm", "generic", "gone", "handlers", "hit", "hook_function_name", "host", "hostname", "hse_append_log_parameter", "hse_req_done_with_session", "hse_req_is_connected", "hse_req_is_keep_conn", "hse_req_map_url_to_path", "hse_req_send_response_header", "hse_req_send_response_header_ex", "hse_req_send_url", "hse_req_send_url_redirect_resp", "html", "htmltable", "https", "iconheight", "iconsarelinks", "iconwidth", "ignore", "ignorecase", "ignoreclient", "ignorecontextinfo", "ignoreinherit", "imal", "in", "includes", "includesnoexec", "indexes", "inherit", "inheritbefore", "inheritdown", "inheritdownbefore", "inode", "input", "int", "integer", "intype", "ipaddr", "is_subreq", "iserror", "last-dot", "last_modified", "ldap", "leaf", "legacyprefixdocroot", "level", "limit", "log_function_name", "major", "manual", "map", "map1", "map2", "max", "md5", "md5-sess", "menu", "merge", "mergebase", "minor", "miss", "mod_cache_disk", "mod_cache_socache", "mode", "mtime", "multiviews", "mutual-failure", "mysql", "name", "namewidth", "ndbm", "negotiatedonly", "never", "no", "nochange", "nocontent", "nodecode", "none", "nonfatal", "note", "number-of-ranges", "odbc", "off", "on", "once", "onerror", "onfail", "option", "optional", "options", "or", "oracle", "order", "original-uri", "os", "output", "outtype", "parent-first", "parent-last", "path", "path_info", "permanent", "pipe", "point", "poly", "postgresql", "prefer", "preservescontentlength", "prg", "protocol", "provider-name", "provider_name", "proxy", "proxy-chain-auth", "proxy-fcgi-pathinfo", "proxy-initial-not-pooled", "proxy-interim-response", "proxy-nokeepalive", "proxy-scgi-pathinfo", "proxy-sendcl", "proxy-sendextracrlf", "proxy-source-port", "proxy-status", "qs", "query_string_unescaped", "range", "ratio", "rect", "referer", "regex", "registry", "registry-strict", "remote_addr", "remote_host", "remote_ident", "remote_user", "remove", "request", "request_filename", "request_rec", "request_scheme", "request_uri", "reset", "revalidate", "rewritecond", "rfc2109", "rnd", "scanhtmltitles", "scope", "script", "sdbm", "searching", "secure", "seeother", "selective", "semiformatted", "server", "server_addr", "server_admin", "server_name", "set", "setifempty", "showforbidden", "size", "sizefmt", "sqlite2", "sqlite3", "ssl", "ssl-access-forbidden", "ssl-secure-reneg", "startbody", "stat", "string", "string1", "subnet", "suppresscolumnsorting", "suppressdescription", "suppresshtmlpreamble", "suppressicon", "suppresslastmodified", "suppressrules", "suppresssize", "symlinksifownermatch", "temp", "temporary", "test_condition1", "the_request", "thread", "timefmt", "tls", "to-pattern", "trackmodified", "transform", "txt", "type", "uctonly", "uid", "unescape", "unformatted", "unlimited", "unset", "uri-pattern", "url", "url-of-terms-of-service", "url-path", "useolddateformat", "value", "value-expression", "var", "versionsort", "virtual", "x-forwarded-for", "x-forwarded-host", "x-forwarded-server", "xhtml"] + DIRECTIVES = Set["accepterrorsnonfatal", "acceptfilter", "acceptmutex", "acceptpathinfo", "accessfilename", "action", "addalt", "addaltbyencoding", "addaltbytype", "addcharset", "adddefaultcharset", "adddescription", "addencoding", "addhandler", "addicon", "addiconbyencoding", "addiconbytype", "addinputfilter", "addlanguage", "addmoduleinfo", "addoutputfilter", "addoutputfilterbytype", "addtype", "alias", "aliasmatch", "aliaspreservepath", "allow", "allowconnect", "allowencodedslashes", "allowhandlers", "allowmethods", "allowoverride", "allowoverridelist", "anonymous", "anonymous_logemail", "anonymous_mustgiveemail", "anonymous_nouserid", "anonymous_verifyemail", "asyncfilter", "authbasicauthoritative", "authbasicfake", "authbasicprovider", "authbasicusedigestalgorithm", "authbearerauthoritative", "authbearerprovider", "authbearerproxy", "authdbduserpwquery", "authdbduserrealmquery", "authdbmgroupfile", "authdbmtype", "authdbmuserfile", "authdigestalgorithm", "authdigestdomain", "authdigestnccheck", "authdigestnonceformat", "authdigestnoncelifetime", "authdigestprovider", "authdigestqop", "authdigestshmemsize", "authformauthoritative", "authformbody", "authformdisablenostore", "authformfakebasicauth", "authformlocation", "authformloginrequiredlocation", "authformloginsuccesslocation", "authformlogoutlocation", "authformmethod", "authformmimetype", "authformpassword", "authformprovider", "authformsitepassphrase", "authformsize", "authformusername", "authgroupfile", "authldapauthorizeprefix", "authldapbindauthoritative", "authldapbinddn", "authldapbindpassword", "authldapcharsetconfig", "authldapcompareasuser", "authldapcomparednonserver", "authldapdereferencealiases", "authldapgroupattribute", "authldapgroupattributeisdn", "authldapinitialbindasuser", "authldapinitialbindpattern", "authldapmaxsubgroupdepth", "authldapremoteuserattribute", "authldapremoteuserisdn", "authldapsearchasuser", "authldapsubgroupattribute", "authldapsubgroupclass", "authldapurl", "authmerging", "authname", "authncachecontext", "authncacheenable", "authncacheprovidefor", "authncachesocache", "authncachetimeout", "authnzfcgicheckauthnprovider", "authnzfcgidefineprovider", "authtjwtclaim", "authtjwtdriver", "authtjwtsign", "authtjwtverify", "authtype", "authuserfile", "authzdbdlogintoreferer", "authzdbdquery", "authzdbdredirectquery", "authzdbmauthoritative", "authzdbmtype", "authzgroupfileauthoritative", "authzownerauthoritative", "authzsendforbiddenonfailure", "authzuserauthoritative", "balancergrowth", "balancerinherit", "balancermember", "balancerpersist", "brotlialteretag", "brotlicompressionmaxinputblock", "brotlicompressionquality", "brotlicompressionwindow", "brotlifilternote", "browsermatch", "browsermatchnocase", "bufferedlogs", "buffersize", "cachedefaultexpire", "cachedetailheader", "cachedirlength", "cachedirlevels", "cachedisable", "cacheenable", "cachefile", "cacheheader", "cacheignorecachecontrol", "cacheignoreheaders", "cacheignorenolastmod", "cacheignorequerystring", "cacheignoreurlsessionidentifiers", "cachekeybaseurl", "cachelastmodifiedfactor", "cachelock", "cachelockmaxage", "cachelockpath", "cachemaxexpire", "cachemaxfilesize", "cacheminexpire", "cacheminfilesize", "cachenegotiateddocs", "cachequickhandler", "cachereadsize", "cachereadtime", "cacheroot", "cachesocache", "cachesocachemaxsize", "cachesocachemaxtime", "cachesocachemintime", "cachesocachereadsize", "cachesocachereadtime", "cachestaleonerror", "cachestoreexpired", "cachestorenostore", "cachestoreprivate", "cgidscripttimeout", "cgimapextension", "cgipassauth", "cgiscripttimeout", "cgivar", "charsetdefault", "charsetoptions", "charsetsourceenc", "checkbasenamematch", "checkcaseonly", "checkspelling", "chrootdir", "contentdigest", "cookiedomain", "cookieexpires", "cookiehttponly", "cookielog", "cookiename", "cookiesamesite", "cookiesecure", "cookiestyle", "cookietracking", "coredumpdirectory", "cryptocipher", "cryptodriver", "cryptoiv", "cryptokey", "cryptosize", "ctauditstorage", "ctlogclient", "ctlogconfigdb", "ctmaxsctage", "ctproxyawareness", "ctsctstorage", "ctserverhellosctlimit", "ctstaticlogconfig", "ctstaticscts", "customlog", "dav", "davbasepath", "davdepthinfinity", "davgenericlockdb", "davlockdb", "davlockdbtype", "davlockdiscovery", "davmintimeout", "davmsext", "davquota", "dbdexptime", "dbdinitsql", "dbdkeep", "dbdmax", "dbdmin", "dbdparams", "dbdpersist", "dbdpreparesql", "dbdriver", "defaulticon", "defaultlanguage", "defaultruntimedir", "defaultstatedir", "defaulttype", "define", "deflatealteretag", "deflatebuffersize", "deflatecompressionlevel", "deflatefilternote", "deflateinflatelimitrequestbody", "deflateinflateratioburst", "deflateinflateratiolimit", "deflatememlevel", "deflatewindowsize", "deny", "directorycheckhandler", "directoryindex", "directoryindexredirect", "directoryslash", "documentroot", "dtraceprivileges", "dumpioinput", "dumpiologlevel", "dumpiooutput", "enableexceptionhook", "enablemmap", "enablesendfile", "error", "errordocument", "errorlog", "errorlogformat", "example", "expiresactive", "expiresbytype", "expiresdefault", "extendedstatus", "extfilterdefine", "extfilteroptions", "fallbackresource", "fileetag", "filterchain", "filterdeclare", "filterprotocol", "filterprovider", "filtertrace", "firehoseconnectioninput", "firehoseconnectionoutput", "firehoseproxyconnectioninput", "firehoseproxyconnectionoutput", "firehoserequestinput", "firehoserequestoutput", "flushmaxpipelined", "flushmaxthreshold", "forcelanguagepriority", "forcetype", "forensiclog", "globallog", "gprofdir", "gracefulshutdowntimeout", "group", "h2copyfiles", "h2direct", "h2earlyhint", "h2earlyhints", "h2maxdataframelen", "h2maxheaderblocklen", "h2maxsessionstreams", "h2maxstreamerrors", "h2maxworkeridleseconds", "h2maxworkers", "h2minworkers", "h2moderntlsonly", "h2outputbuffering", "h2padding", "h2proxyrequests", "h2push", "h2pushdiarysize", "h2pushpriority", "h2pushresource", "h2serializeheaders", "h2streammaxmemsize", "h2streamtimeout", "h2tlscooldownsecs", "h2tlswarmupsize", "h2upgrade", "h2websockets", "h2windowsize", "header", "headername", "heartbeataddress", "heartbeatlisten", "heartbeatmaxservers", "heartbeatstorage", "hostnamelookups", "httpprotocoloptions", "identitycheck", "identitychecktimeout", "imapbase", "imapdefault", "imapmenu", "include", "includeoptional", "indexforbiddenreturn404", "indexheadinsert", "indexignore", "indexignorereset", "indexoptions", "indexorderdefault", "indexstylesheet", "inputsed", "isapiappendlogtoerrors", "isapiappendlogtoquery", "isapicachefile", "isapifakeasync", "isapilognotsupported", "isapireadaheadbuffer", "keepalive", "keepalivetimeout", "keptbodysize", "languagepriority", "ldapcacheentries", "ldapcachettl", "ldapconnectionpoolttl", "ldapconnectiontimeout", "ldaplibrarydebug", "ldapopcacheentries", "ldapopcachettl", "ldapreferralhoplimit", "ldapreferrals", "ldapretries", "ldapretrydelay", "ldapsharedcachefile", "ldapsharedcachesize", "ldaptimeout", "ldaptrustedclientcert", "ldaptrustedglobalcert", "ldaptrustedmode", "ldapverifyservercert", "limitinternalrecursion", "limitrequestbody", "limitrequestfields", "limitrequestfieldsize", "limitrequestline", "limitxmlrequestbody", "listen", "listenbacklog", "listencoresbucketsratio", "listentcpdeferaccept", "loadfile", "loadmodule", "lockfile", "logformat", "logiotrackttfb", "logiotrackttfu", "loglevel", "logleveloverride", "logmessage", "luaauthzprovider", "luacodecache", "luahookaccesschecker", "luahookauthchecker", "luahookcheckuserid", "luahookfixups", "luahookinsertfilter", "luahooklog", "luahookmaptostorage", "luahookpretranslate", "luahooktranslatename", "luahooktypechecker", "luainherit", "luainputfilter", "luamaphandler", "luaoutputfilter", "luapackagecpath", "luapackagepath", "luaquickhandler", "luaroot", "luascope", "macroignorebadnesting", "macroignoreemptyargs", "maxclients", "maxconnectionsperchild", "maxkeepaliverequests", "maxmemfree", "maxrangeoverlaps", "maxrangereversals", "maxranges", "maxrequestsperchild", "maxrequestworkers", "maxspareservers", "maxsparethreads", "maxthreads", "mdactivationdelay", "mdbaseserver", "mdcacertificatefile", "mdcachallenges", "mdcertificateagreement", "mdcertificateauthority", "mdcertificatecheck", "mdcertificatefile", "mdcertificatekeyfile", "mdcertificatemonitor", "mdcertificateprotocol", "mdcertificatestatus", "mdchallengedns01", "mdchallengedns01version", "mdcheckinterval", "mdcontactemail", "mddrivemode", "mdexternalaccountbinding", "mdhttpproxy", "mdinitialdelay", "mdmatchnames", "mdmember", "mdmembers", "mdmessagecmd", "mdmuststaple", "mdnotifycmd", "mdomain", "mdportmap", "mdprivatekeys", "mdprofile", "mdprofilemandatory", "mdrenewmode", "mdrenewviaari", "mdrenewwindow", "mdrequirehttps", "mdretrydelay", "mdretryfailover", "mdserverstatus", "mdstapleothers", "mdstapling", "mdstaplingkeepresponse", "mdstaplingrenewwindow", "mdstoredir", "mdstorelocks", "mdwarnwindow", "memcacheconnttl", "mergeslashes", "mergetrailers", "metadir", "metafiles", "metasuffix", "mimemagicfile", "mimeoptions", "minspareservers", "minsparethreads", "mmapfile", "modemstandard", "modmimeusepathinfo", "multiviewsmatch", "mutex", "namevirtualhost", "noproxy", "nwssltrustedcerts", "nwsslupgradeable", "options", "order", "outputsed", "passenv", "pidfile", "policyconditional", "policyconditionalurl", "policyenvironment", "policyfilter", "policykeepalive", "policykeepaliveurl", "policylength", "policylengthurl", "policymaxage", "policymaxageurl", "policynocache", "policynocacheurl", "policytype", "policytypeurl", "policyvalidation", "policyvalidationurl", "policyvary", "policyvaryurl", "policyversion", "policyversionurl", "privilegesmode", "protocol", "protocolecho", "protocols", "protocolshonororder", "proxy100continue", "proxyaddheaders", "proxybadheader", "proxyblock", "proxydomain", "proxyerroroverride", "proxyexpressdbmfile", "proxyexpressdbmtype", "proxyexpressenable", "proxyfcgibackendtype", "proxyfcgisetenvif", "proxyftpdircharset", "proxyftpescapewildcards", "proxyftplistonwildcard", "proxyhcexpr", "proxyhctemplate", "proxyhctpsize", "proxyhtmlbufsize", "proxyhtmlcharsetout", "proxyhtmldoctype", "proxyhtmlenable", "proxyhtmlevents", "proxyhtmlextended", "proxyhtmlfixups", "proxyhtmlinterp", "proxyhtmllinks", "proxyhtmlmeta", "proxyhtmlstripcomments", "proxyhtmlurlmap", "proxyiobuffersize", "proxymaxforwards", "proxypass", "proxypassinherit", "proxypassinterpolateenv", "proxypassmatch", "proxypassreverse", "proxypassreversecookiedomain", "proxypassreversecookiepath", "proxypreservehost", "proxyreceivebuffersize", "proxyremote", "proxyremotematch", "proxyrequests", "proxyscgiinternalredirect", "proxyscgisendfile", "proxyset", "proxysourceaddress", "proxystatus", "proxytimeout", "proxyvia", "proxywebsocketasync", "proxywebsocketasyncdelay", "proxywebsocketfallbacktoproxyhttp", "proxywebsocketidletimeout", "qualifyredirecturl", "readbuffersize", "readmename", "receivebuffersize", "redirect", "redirectmatch", "redirectpermanent", "redirectrelative", "redirecttemp", "redisconnpoolttl", "redistimeout", "reflectorheader", "regexdefaultoptions", "registerhttpmethod", "remoteipheader", "remoteipinternalproxy", "remoteipinternalproxylist", "remoteipproxiesheader", "remoteipproxyprotocol", "remoteipproxyprotocolexceptions", "remoteiptrustedproxy", "remoteiptrustedproxylist", "removecharset", "removeencoding", "removehandler", "removeinputfilter", "removelanguage", "removeoutputfilter", "removetype", "requestheader", "requestreadtimeout", "require", "rewritebase", "rewritecond", "rewriteengine", "rewritemap", "rewriteoptions", "rewriterule", "rlimitcpu", "rlimitmem", "rlimitnproc", "satisfy", "scoreboardfile", "script", "scriptalias", "scriptaliasmatch", "scriptinterpretersource", "scriptlog", "scriptlogbuffer", "scriptloglength", "scriptsock", "securelisten", "seerequesttail", "sendbuffersize", "serveradmin", "serveralias", "serverlimit", "servername", "serverpath", "serverroot", "serversignature", "servertokens", "session", "sessioncookiemaxage", "sessioncookiename", "sessioncookiename2", "sessioncookieremove", "sessioncryptocipher", "sessioncryptodriver", "sessioncryptopassphrase", "sessioncryptopassphrasefile", "sessiondbdcookiename", "sessiondbdcookiename2", "sessiondbdcookieremove", "sessiondbddeletelabel", "sessiondbdinsertlabel", "sessiondbdperuser", "sessiondbdselectlabel", "sessiondbdupdatelabel", "sessionenv", "sessionexclude", "sessionexpiryupdateinterval", "sessionheader", "sessioninclude", "sessionmaxage", "setenv", "setenvif", "setenvifexpr", "setenvifnocase", "sethandler", "setinputfilter", "setoutputfilter", "ssiaccessenable", "ssiendtag", "ssierrormsg", "ssietag", "ssilastmodified", "ssilegacyexprparser", "ssistarttag", "ssitimeformat", "ssiundefinedecho", "sslcacertificatefile", "sslcacertificatepath", "sslcadnrequestfile", "sslcadnrequestpath", "sslcarevocationcheck", "sslcarevocationfile", "sslcarevocationpath", "sslcertificatechainfile", "sslcertificatefile", "sslcertificatekeyfile", "sslciphersuite", "sslclienthellovars", "sslcompression", "sslcryptodevice", "sslechkeydir", "sslengine", "sslfips", "sslhonorcipherorder", "sslinsecurerenegotiation", "sslocspdefaultresponder", "sslocspenable", "sslocspnoverify", "sslocspoverrideresponder", "sslocspproxyurl", "sslocsprespondercertificatefile", "sslocsprespondertimeout", "sslocspresponsemaxage", "sslocspresponsetimeskew", "sslocspuserequestnonce", "sslopensslconfcmd", "ssloptions", "sslpassphrasedialog", "sslpolicy", "sslprotocol", "sslproxycacertificatefile", "sslproxycacertificatepath", "sslproxycarevocationcheck", "sslproxycarevocationfile", "sslproxycarevocationpath", "sslproxycheckpeercn", "sslproxycheckpeerexpire", "sslproxycheckpeername", "sslproxyciphersuite", "sslproxyengine", "sslproxymachinecertificatechainfile", "sslproxymachinecertificatefile", "sslproxymachinecertificatepath", "sslproxypolicy", "sslproxyprotocol", "sslproxyverify", "sslproxyverifydepth", "sslrandomseed", "sslrenegbuffersize", "sslrequire", "sslrequiressl", "sslsessioncache", "sslsessioncachetimeout", "sslsessionticketkeyfile", "sslsessiontickets", "sslsrpunknownuserseed", "sslsrpverifierfile", "sslstaplingcache", "sslstaplingerrorcachetimeout", "sslstaplingfaketrylater", "sslstaplingforceurl", "sslstaplingrespondertimeout", "sslstaplingresponsemaxage", "sslstaplingresponsetimeskew", "sslstaplingreturnrespondererrors", "sslstaplingstandardcachetimeout", "sslstrictsnivhostcheck", "sslusername", "sslusestapling", "sslverifyclient", "sslverifydepth", "sslvhostsnipolicy", "startservers", "startthreads", "stricthostcheck", "substitute", "substituteinheritbefore", "substitutemaxlinelength", "suexec", "suexecusergroup", "threadlimit", "threadsperchild", "threadstacksize", "timeout", "traceenable", "transferlog", "typesconfig", "unclist", "undefine", "undefmacro", "unsetenv", "use", "usecanonicalname", "usecanonicalphysicalport", "user", "userdir", "vhostcgimode", "vhostcgiprivs", "vhostgroup", "vhostprivs", "vhostsecure", "vhostuser", "virtualdocumentroot", "virtualdocumentrootip", "virtualscriptalias", "virtualscriptaliasip", "warning", "watchdoginterval", "xbithack", "xml2encalias", "xml2encdefault", "xml2startparse"] + VALUES = Set["accepted", "add", "addsuffix", "all", "alllastextension", "allowanyuri", "allownoslash", "always", "and", "any", "api_version", "append", "ascending", "auth", "auth-int", "authbasicprovider", "authn", "authnz", "authonly", "authz", "auto", "base", "basic", "before", "block", "byteranges", "cache", "cgi", "chain", "change", "charset", "check_user_id", "circle", "cmd", "conn", "conn_remote_addr", "connection", "cookie", "cookie2", "current-uri", "date", "date_gmt", "date_local", "db", "debuglevel", "decoding", "default", "descending", "description", "descriptionwidth", "digest", "directory", "disable", "disabled", "disableenv", "dns", "document_args", "document_name", "document_path_info", "document_uri", "dollar_endonly", "dotall", "double", "duration", "early", "echo", "echomsg", "edit", "edit*", "email", "enable", "enableenv", "encoding", "entier", "env", "errmsg", "error", "es", "execcgi", "expr", "extended", "fallback", "fancyindexing", "fast", "fcntl", "file", "filter_name", "filters", "finding", "flock", "foldersfirst", "followsymlinks", "forever", "form", "formatted", "fpm", "from", "ftype", "full", "function_name", "gdbm", "generic", "gone", "handlers", "hook_function_name", "host", "hse_append_log_parameter", "hse_req_done_with_session", "hse_req_is_connected", "hse_req_is_keep_conn", "hse_req_map_url_to_path", "hse_req_send_response_header", "hse_req_send_response_header_ex", "hse_req_send_url", "hse_req_send_url_redirect_resp", "html", "html5or", "htmltable", "https", "icase", "iconheight", "iconsarelinks", "iconwidth", "ignore", "ignorecase", "ignoreclient", "ignorecontextinfo", "ignoreinherit", "imal", "includes", "includesnoexec", "indexes", "inherit", "inheritbefore", "inheritdown", "inheritdownbefore", "input", "insecure", "integer", "intype", "is_subreq", "iserror", "last_modified", "lax", "leaf", "legacyprefixdocroot", "level", "log", "log_function_name", "longurloptimization", "major", "manual", "map", "max", "md5", "md5-sess", "menu", "merge", "mergebase", "minor", "mode", "modele-uri", "ms", "multiviews", "mutual-failure", "name", "namewidth", "ndbm", "negotiatedonly", "netscape", "network", "never", "no", "noalllastextension", "nochange", "nocontent", "nodecode", "nom_fonction_hook", "none", "note", "notfound", "notypeslastextension", "off", "on", "once", "onerror", "onfail", "optional", "or", "original-uri", "os", "output", "outtype", "parent-first", "parent-last", "permanent", "point", "poly", "posixsem", "prefer", "preservescontentlength", "provider_name", "proxy", "proxyhtmldoctype", "pthread", "qs", "query_string_unescaped", "range", "ratio", "rect", "referer", "registry", "registry-strict", "remote_addr", "remove", "request", "request_filename", "request_hostname", "request_scheme", "request_uri", "request_user", "request_useragent_ip", "require", "reset", "rfc2109", "rfc2965", "scanhtmltitles", "script", "sdbm", "searching", "secure", "seeother", "selective", "sem", "semiformatted", "server", "server_hostname", "servernames", "set", "setifempty", "showforbidden", "size", "sizefmt", "ssl", "ssl-access-forbidden", "ssl-secure-reneg", "startbody", "stat", "strict", "suppresscolumnsorting", "suppressdescription", "suppresshtmlpreamble", "suppressicon", "suppresslastmodified", "suppressrules", "suppresssize", "symlinksifownermatch", "sysvsem", "temp", "temporary", "the_request", "thread", "timefmt", "tls", "trackmodified", "transform", "typeslastextension", "uctonly", "uid", "unformatted", "unlimited", "unset", "uri-pattern", "url", "user_name", "value", "var", "versionsort", "virtual", "x-forwarded-for", "x-forwarded-host", "x-forwarded-server", "xhtml"] + SECTIONS = Set["authnprovideralias", "authtprovideralias", "authzprovideralias", "directory", "directorymatch", "else", "elseif", "files", "filesmatch", "if", "ifdefine", "ifdirective", "iffile", "ifmodule", "ifsection", "ifversion", "limit", "limitexcept", "location", "locationmatch", "macro", "mdomainset", "proxy", "proxymatch", "requireall", "requireany", "requirenone", "sslpolicydefine", "virtualhost"] end end end diff --git a/tasks/builtins/apache.rake b/tasks/builtins/apache.rake index 2eba4f0238..e192e0b602 100644 --- a/tasks/builtins/apache.rake +++ b/tasks/builtins/apache.rake @@ -1,124 +1,110 @@ # -*- coding: utf-8 -*- # # frozen_string_literal: true -require 'open-uri' +require_relative '../task_helper' + +# backcompat for ancient net/dav lib +def File.exists?(p) + File.exist?(p) +end + +# And it still warns a lot. +silence_warnings { require 'net/dav' } + +require 'nokogiri' +require 'svn/downloader' APACHE_DOCS_URI = "https://downloads.apache.org/httpd/docs/" APACHE_KEYWORDS_FILE = "./lib/rouge/lexers/apache/keywords.rb" namespace :builtins do task :apache do - STDERR.puts "SKIP: rewrite the apache fetcher as the source appears to have been removed." - next - generator = Rouge::Tasks::Builtins::Apache.new + ApacheBuiltins.process(APACHE_KEYWORDS_FILE) + end +end - input = URI.open(APACHE_DOCS_URI) { |f| f.read } - files = generator.download_docs(input) - list = files.delete("directives.html") - mods = files.values +class ApacheBuiltins < BuiltinsGenerator + APACHE_MOD_DOCS = 'https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/manual/mod/' - keywords = generator.extract_keywords(list) - values = generator.extract_values(mods) + BASE_PATH = File.expand_path("#{__dir__}/../../tmp/apache-mods") - output = generator.render_output(keywords, values) + def fetch + SVN::Downloader.download(APACHE_MOD_DOCS, BASE_PATH) - File.write(APACHE_KEYWORDS_FILE, output) + files = {} + + Dir.chdir BASE_PATH do + Dir.glob("{directives,core,prefork,mod_*,mpm*}.xml*").each do |f| + files[File.basename(f)] = File.read(f) + end + end + + files end -end -module Rouge - module Tasks - module Builtins - class Apache - def download_docs(input) - files = Hash.new - - name, ext = input.match(/href="(.+\.en)(\.zip)"/) { |m| [m[1], m[2]] } - docs_zip = APACHE_DOCS_URI + name + ext - - system "mkdir -p /tmp/rouge" - Dir.chdir "/tmp/rouge" do - system "wget -q #{docs_zip}" - system "unzip -oq #{name + ext}" - Dir.chdir "./#{name}/mod/" do - Dir.glob("./{directives,core,mod_*,mpm*}.html").each do |f| - files[File.basename(f)] = File.read(f) - end - end - end - - files - end + WORD_VALUE = /\A\w[\w*-]+\z/o - def extract_keywords(input) - keywords = Hash.new { |h,k| h[k] = Array.new } + def parse + out = Hash.new { |h, k| h[k] = Set.new } - input.each_line do |line| - if line.scrub =~ %r(
  • (<)?(.*?)(>)?
  • ) - next unless $2 + @input.each do |name, content| + xml = Nokogiri::XML(content) - if $1 && $3 - key = "sections" - else - key = "directives" - end + xml.css('directivesynopsis').each do |synopsis| + name = synopsis.css('name').inner_text.strip + syntax = synopsis.css('syntax') - keywords[key].push $2.downcase - end - end + # anything in a or tag is a variable description, and not a constant + syntax.css('var').remove + syntax.css('em').remove - keywords - end + # detect constants in command arguments + + values = syntax.inner_text.strip + .gsub(/\A\w+\s*/, '') + .split(/[|\s]+/) + .grep(WORD_VALUE) - def extract_values(inputs) - values = Set.new - - inputs.each do |input| - input = input.scrub - input.scan(%r[Syntax:.*?(.*?)]m) do |m| - m[0].split(/[\s|]/). - drop(1). - filter { |v| v.index(/^\w[\w*-]+$/) }. - each { |v| values.add(v.downcase) } - end - - input.scan(%r[
    \s*(?:<.+?>\s*)*(.*?)<]m) do |m| - m[0].split(/[=\[\]]/). - filter { |v| v.index(/^\w[\w*-]+$/) }. - each { |v| values.add(v.downcase) } - end - end - - values.to_a.sort + values.each do |value| + out[:values] << value.strip.downcase end - def render_output(keywords, values, &b) - return enum_for(:render_output, keywords, values).to_a.join("\n") unless b - - yield "# -*- coding: utf-8 -*- #" - yield "# frozen_string_literal: true" - yield "" - yield "# DO NOT EDIT" - yield "# This file is automatically generated by `rake builtins:apache`." - yield "# See tasks/builtins/apache.rake for more info." - yield "" - yield "module Rouge" - yield " module Lexers" - yield " class Apache" - keywords.each do |k,v| - yield " def self.#{k}" - yield " @#{k} ||= Set.new #{v.inspect}" - yield " end" - yield "" - end - yield " def self.values" - yield " @values ||= Set.new #{values.inspect}" - yield " end" - yield " end" - yield " end" - yield "end" + name = name.downcase + + if synopsis.attr('type') == "section" + out[:sections] << name + else + out[:directives] << name end end + + xml.css('usage dt code, section dt code').each do |el| + el.children.reject(&:text?).each(&:remove) + value = el.inner_text.strip.downcase + + value.split(/[=\[\]]+/).grep(WORD_VALUE).each { |v| out[:values] << v } + end end + + out + end + + def generate + yield "# -*- coding: utf-8 -*- #" + yield "# frozen_string_literal: true" + yield "" + yield "# DO NOT EDIT" + yield "# This file is automatically generated by `rake builtins:apache`." + yield "# See tasks/builtins/apache.rake for more info." + yield "" + yield "module Rouge" + yield " module Lexers" + yield " class Apache" + yield " DIRECTIVES = Set#{@keywords[:directives].sort.inspect}" + yield " VALUES = Set#{@keywords[:values].sort.inspect}" + yield " SECTIONS = Set#{@keywords[:sections].sort.inspect}" + yield " end" + yield " end" + yield "end" end end diff --git a/tasks/task_helper.rb b/tasks/task_helper.rb index 7acd35893f..2cb093ced4 100644 --- a/tasks/task_helper.rb +++ b/tasks/task_helper.rb @@ -1,5 +1,12 @@ require 'open-uri' +def silence_warnings + old_verbose, $VERBOSE = $VERBOSE, false + yield +ensure + $VERBOSE = old_verbose +end + class BuiltinsGenerator def self.process(fname, *a) new(*a).process(fname)