diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gen_vimdoc.py | 45 | ||||
-rw-r--r-- | scripts/lua2dox.lua | 36 | ||||
-rwxr-xr-x | scripts/release.sh | 6 | ||||
-rwxr-xr-x | scripts/shadacat.py | 2 | ||||
-rwxr-xr-x | scripts/update_version_stamp.lua | 55 | ||||
-rwxr-xr-x | scripts/vim-patch.sh | 76 |
6 files changed, 142 insertions, 78 deletions
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 373a58d11e..4d71d5e15e 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -36,11 +36,12 @@ import shutil import textwrap import subprocess import collections +import msgpack from xml.dom import minidom -if sys.version_info[0] < 3: - print("use Python 3") +if sys.version_info[0] < 3 or sys.version_info[1] < 5: + print("requires Python 3.5+") sys.exit(1) DEBUG = ('DEBUG' in os.environ) @@ -84,7 +85,7 @@ CONFIG = { 'append_only': [], }, 'lua': { - 'filename': 'if_lua.txt', + 'filename': 'lua.txt', 'section_start_token': '*lua-vim*', 'section_order': [ 'vim.lua', @@ -453,7 +454,7 @@ def parse_source_xml(filename, mode): """ global xrefs xrefs = set() - functions = [] + functions = {} # Map of func_name:docstring. deprecated_functions = [] dom = minidom.parse(filename) @@ -577,11 +578,13 @@ def parse_source_xml(filename, mode): if 'Deprecated' in xrefs: deprecated_functions.append(func_doc) elif name.startswith(CONFIG[mode]['func_name_prefix']): - functions.append(func_doc) + functions[name] = func_doc xrefs.clear() - return '\n\n'.join(functions), '\n\n'.join(deprecated_functions) + return ('\n\n'.join(list(functions.values())), + '\n\n'.join(deprecated_functions), + functions) def delete_lines_below(filename, tokenstr): @@ -604,6 +607,13 @@ def gen_docs(config): Doxygen is called and configured through stdin. """ for mode in CONFIG: + functions = {} # Map of func_name:docstring. + mpack_file = os.path.join( + base_dir, 'runtime', 'doc', + CONFIG[mode]['filename'].replace('.txt', '.mpack')) + if os.path.exists(mpack_file): + os.remove(mpack_file) + output_dir = out_dir.format(mode=mode) p = subprocess.Popen(['doxygen', '-'], stdin=subprocess.PIPE) p.communicate( @@ -645,14 +655,15 @@ def gen_docs(config): filename = get_text(find_first(compound, 'name')) if filename.endswith('.c') or filename.endswith('.lua'): - functions, deprecated = parse_source_xml( - os.path.join(base, '%s.xml' % - compound.getAttribute('refid')), mode) + functions_text, deprecated_text, fns = parse_source_xml( + os.path.join(base, '{}.xml'.format( + compound.getAttribute('refid'))), mode) + # Collect functions from all modules (for the current `mode`). + functions = {**functions, **fns} - if not functions and not deprecated: + if not functions_text and not deprecated_text: continue - - if functions or deprecated: + else: name = os.path.splitext(os.path.basename(filename))[0] if name == 'ui': name = name.upper() @@ -665,12 +676,12 @@ def gen_docs(config): if intro: doc += '\n\n' + intro - if functions: - doc += '\n\n' + functions + if functions_text: + doc += '\n\n' + functions_text - if INCLUDE_DEPRECATED and deprecated: + if INCLUDE_DEPRECATED and deprecated_text: doc += '\n\n\nDeprecated %s Functions: ~\n\n' % name - doc += deprecated + doc += deprecated_text if doc: filename = os.path.basename(filename) @@ -713,6 +724,8 @@ def gen_docs(config): delete_lines_below(doc_file, CONFIG[mode]['section_start_token']) with open(doc_file, 'ab') as fp: fp.write(docs.encode('utf8')) + with open(mpack_file, 'wb') as fp: + fp.write(msgpack.packb(functions, use_bin_type=True)) shutil.rmtree(output_dir) diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index 77cdabcc4b..171621e38d 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -65,7 +65,7 @@ FILTER_PATTERNS = *.lua=lua2dox_filter Either add them to the end or find the appropriate entry in Doxyfile. -There are other lines that you might like to alter, but see futher documentation for details. +There are other lines that you might like to alter, but see further documentation for details. <li> When Doxyfile is edited run "doxygen" @@ -543,7 +543,6 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename) local fn = TString_removeCommentFromLine(string_trim(string.sub(line,pos_fn+8))) if fn_magic then fn = fn_magic - fn_magic = nil end if string.sub(fn,1,1)=='(' then @@ -554,49 +553,20 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename) -- want to fix for iffy declarations local open_paren = string.find(fn,'[%({]') - local fn0 = fn if open_paren then - fn0 = string.sub(fn,1,open_paren-1) -- we might have a missing close paren if not string.find(fn,'%)') then fn = fn .. ' ___MissingCloseParenHere___)' end end - local dot = string.find(fn0,'[%.:]') - if dot then -- it's a method - local klass = string.sub(fn,1,dot-1) - local method = string.sub(fn,dot+1) - --TCore_IO_writeln('function ' .. klass .. '::' .. method .. ftail .. '{}') - --TCore_IO_writeln(klass .. '::' .. method .. ftail .. '{}') - outStream:writeln( - '/*! \\memberof ' .. klass .. ' */ ' - .. method .. '{}' - ) - else - -- add vanilla function - - outStream:writeln(fn_type .. 'function ' .. fn .. '{}') - end + -- add vanilla function + outStream:writeln(fn_type .. 'function ' .. fn .. '{}') end else this:warning(inStream:getLineNo(),'something weird here') end fn_magic = nil -- mustn't indavertently use it again - elseif string.find(line,'=%s*class%(') then - state = 'in_class' -- it's a class declaration - local tailComment - line,tailComment = TString_removeCommentFromLine(line) - local equals = string.find(line,'=') - local klass = string_trim(string.sub(line,1,equals-1)) - local tail = string_trim(string.sub(line,equals+1)) - -- class(wibble wibble) - -- ....v. - local parent = string.sub(tail,7,-2) - if #parent>0 then - parent = ' :public ' .. parent - end - outStream:writeln('class ' .. klass .. parent .. '{};') else state = '' -- unknown if #line>0 then -- we don't know what this line means, so just comment it out diff --git a/scripts/release.sh b/scripts/release.sh index 29d61370ce..5b4902a2d7 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -80,7 +80,7 @@ _do_bump_commit() { <release date="'"${__DATE}"'" version="xxx"/>,' runtime/nvim.appdata.xml rm CMakeLists.txt.bk rm runtime/nvim.appdata.xml.bk - nvim +'/NVIM_VERSION' +1new +'exe "norm! iUpdate version numbers!!!\<CR>"' \ + nvim +'/NVIM_VERSION' +1new +'exe "norm! iUpdate version numbers!!!"' \ -O CMakeLists.txt runtime/nvim.appdata.xml git add CMakeLists.txt runtime/nvim.appdata.xml @@ -93,8 +93,8 @@ fi _do_bump_commit echo " Next steps: - - Double-check NVIM_VERSION_* in CMakeLists.txt - - Double-check runtime/nvim.appdata.xml + - Update runtime/nvim.appdata.xml on _master_ + - Run tests/CI (version_spec.lua)! - Push the tag: git push --follow-tags - Update the 'stable' tag: diff --git a/scripts/shadacat.py b/scripts/shadacat.py index 89846427a5..2b71fc2385 100755 --- a/scripts/shadacat.py +++ b/scripts/shadacat.py @@ -66,7 +66,7 @@ except IndexError: def filt(entry): return True else: _filt = filt - def filt(entry): return eval(_filt, globals(), {'entry': entry}) + def filt(entry): return eval(_filt, globals(), {'entry': entry}) # noqa poswidth = len(str(os.stat(fname).st_size or 1000)) diff --git a/scripts/update_version_stamp.lua b/scripts/update_version_stamp.lua new file mode 100755 index 0000000000..11b521fab6 --- /dev/null +++ b/scripts/update_version_stamp.lua @@ -0,0 +1,55 @@ +#!/usr/bin/env lua +-- +-- Script to update the Git version stamp during build. +-- This is called via the custom update_version_stamp target in +-- src/nvim/CMakeLists.txt. +-- +-- arg[1]: file in which to update the version string +-- arg[2]: prefix to use always ("vX.Y.Z") + +local function die(msg) + io.stderr:write(string.format('%s: %s\n', arg[0], msg)) + -- No error, fall back to using generated "-dev" version. + os.exit(0) +end + +local function iswin() + return package.config:sub(1,1) == '\\' +end + +if #arg ~= 2 then + die(string.format("Expected two args, got %d", #arg)) +end + +local versiondeffile = arg[1] +local prefix = arg[2] + +local dev_null = iswin() and 'NUL' or '/dev/null' +local described = io.popen('git describe --first-parent --dirty 2>'..dev_null):read('*l') +if not described then + described = io.popen('git describe --first-parent --tags --always --dirty'):read('*l') +end +if not described then + io.open(versiondeffile, 'w'):write('\n') + die('git-describe failed, using empty include file.') +end + +-- `git describe` annotates the most recent tagged release; for pre-release +-- builds we must replace that with the unreleased version. +local with_prefix = described:gsub("^v%d+%.%d+%.%d+", prefix) +if described == with_prefix then + -- Prepend the prefix always, e.g. with "nightly-12208-g4041b62b9". + with_prefix = prefix .. "-" .. described +end + +-- Read existing include file. +local current = io.open(versiondeffile, 'r') +if current then + current = current:read('*l') +end + +-- Write new include file, if different. +local new = '#define NVIM_VERSION_MEDIUM "'..with_prefix..'"' +if current ~= new then + io.open(versiondeffile, 'w'):write(new .. '\n') +end diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 2cc32f0dd0..b6a0df4649 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -89,7 +89,7 @@ get_vim_sources() { echo "Cloning Vim into: ${VIM_SOURCE_DIR}" git clone https://github.com/vim/vim.git "${VIM_SOURCE_DIR}" cd "${VIM_SOURCE_DIR}" - else + elif [[ "${1-}" == update ]]; then cd "${VIM_SOURCE_DIR}" if ! [ -d ".git" ] \ && ! [ "$(git rev-parse --show-toplevel)" = "${VIM_SOURCE_DIR}" ]; then @@ -103,6 +103,8 @@ get_vim_sources() { else msg_err "Could not update Vim sources; ignoring error." fi + else + cd "${VIM_SOURCE_DIR}" fi } @@ -124,7 +126,7 @@ find_git_remote() { } # Assign variables for a given Vim tag, patch version, or commit. -# Might exit in case it cannot be found. +# Might exit in case it cannot be found, after updating Vim sources. assign_commit_details() { local vim_commit_ref if [[ ${1} =~ v?[0-9]\.[0-9]\.[0-9]{3,4} ]]; then @@ -146,9 +148,14 @@ assign_commit_details() { local munge_commit_line=false fi - vim_commit=$(git -C "${VIM_SOURCE_DIR}" log -1 --format="%H" "${vim_commit_ref}" --) || { - >&2 msg_err "Couldn't find Vim revision '${vim_commit_ref}'." - exit 3 + local get_vim_commit_cmd="git -C ${VIM_SOURCE_DIR} log -1 --format=%H ${vim_commit_ref} --" + vim_commit=$($get_vim_commit_cmd 2>&1) || { + # Update Vim sources. + get_vim_sources update + vim_commit=$($get_vim_commit_cmd 2>&1) || { + >&2 msg_err "Couldn't find Vim revision '${vim_commit_ref}': git error: ${vim_commit}." + exit 3 + } } vim_commit_url="https://github.com/vim/vim/commit/${vim_commit}" @@ -366,7 +373,7 @@ submit_pr() { # Gets all Vim commits since the "start" commit. list_vim_commits() { ( - cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v8.0.0000..HEAD "$@" + cd "${VIM_SOURCE_DIR}" && git log --reverse v8.0.0000..HEAD "$@" ) } # Prints all (sorted) "vim-patch:xxx" tokens found in the Nvim git log. @@ -389,6 +396,7 @@ list_vimpatch_numbers() { } # Prints a newline-delimited list of Vim commits, for use by scripts. +# "$1": use extended format? # "$@" is passed to list_vim_commits, as extra arguments to git-log. list_missing_vimpatches() { local token vim_commit vim_tag patch_number @@ -396,6 +404,13 @@ list_missing_vimpatches() { declare -A vim_commit_tags declare -a git_log_args + local extended_format=$1; shift + if [[ "$extended_format" == 1 ]]; then + git_log_args=("--format=%H %s") + else + git_log_args=("--format=%H") + fi + # Massage arguments for git-log. declare -A git_log_replacements=( [^\(.*/\)?src/nvim/\(.*\)]="\${BASH_REMATCH[1]}src/\${BASH_REMATCH[2]}" @@ -431,13 +446,27 @@ list_missing_vimpatches() { # Get missing Vim commits set +u # Avoid "unbound variable" with bash < 4.4 below. - for vim_commit in $(list_vim_commits "${git_log_args[@]}"); do + local vim_commit info + while IFS=' ' read -r line; do # Check for vim-patch:<commit_hash> (usually runtime updates). - token="vim-patch:${vim_commit:0:7}" + token="vim-patch:${line:0:7}" if [[ "${tokens[$token]-}" ]]; then continue fi + # Get commit hash, and optional info from line. This is used in + # extended mode, and when using e.g. '--format' manually. + vim_commit=${line%% *} + if [[ "$vim_commit" == "$line" ]]; then + info= + else + info=${line#* } + if [[ -n $info ]]; then + # Remove any "patch 8.0.0902: " prefixes, and prefix with ": ". + info=": ${info#patch*: }" + fi + fi + vim_tag="${vim_commit_tags[$vim_commit]-}" if [[ -n "$vim_tag" ]]; then # Check for vim-patch:<tag> (not commit hash). @@ -445,26 +474,26 @@ list_missing_vimpatches() { if [[ "${tokens[$patch_number]-}" ]]; then continue fi - echo "$vim_tag" + printf '%s%s\n' "$vim_tag" "$info" else - echo "$vim_commit" + printf '%s%s\n' "$vim_commit" "$info" fi - done + done < <(list_vim_commits "${git_log_args[@]}") set -u } # Prints a human-formatted list of Vim commits, with instructional messages. # Passes "$@" onto list_missing_vimpatches (args for git-log). show_vimpatches() { - get_vim_sources - printf "\nVim patches missing from Neovim:\n" + get_vim_sources update + printf "Vim patches missing from Neovim:\n" local -A runtime_commits for commit in $(git -C "${VIM_SOURCE_DIR}" log --format="%H %D" -- runtime | sed 's/,\? tag: / /g'); do runtime_commits[$commit]=1 done - list_missing_vimpatches "$@" | while read -r vim_commit; do + list_missing_vimpatches 1 "$@" | while read -r vim_commit; do if [[ "${runtime_commits[$vim_commit]-}" ]]; then printf ' • %s (+runtime)\n' "${vim_commit}" else @@ -472,18 +501,15 @@ show_vimpatches() { fi done - printf "Instructions: - - To port one of the above patches to Neovim, execute - this script with the patch revision as argument and - follow the instructions. + cat << EOF - Examples: '%s -p 7.4.487' - '%s -p 1e8ebf870720e7b671f98f22d653009826304c4f' +Instructions: + To port one of the above patches to Neovim, execute this script with the patch revision as argument and follow the instructions, e.g. + '${BASENAME} -p v8.0.1234', or '${BASENAME} -P v8.0.1234' NOTE: Please port the _oldest_ patch if you possibly can. - Out-of-order patches increase the possibility of bugs. -" "${BASENAME}" "${BASENAME}" + You can use '${BASENAME} -l path/to/file' to see what patches are missing for a file. +EOF } review_commit() { @@ -596,7 +622,7 @@ while getopts "hlLMVp:P:g:r:s" opt; do ;; L) shift # remove opt - list_missing_vimpatches "$@" + list_missing_vimpatches 0 "$@" exit 0 ;; M) @@ -624,7 +650,7 @@ while getopts "hlLMVp:P:g:r:s" opt; do exit 0 ;; V) - get_vim_sources + get_vim_sources update exit 0 ;; *) |