New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create_manpage_completions.py: introduce Type5ManParser which is capable of parsing scdoc manpages; add 'return' statements to other parsers; cleanup #7187
Conversation
Bug: poor performance, will fix soon |
Fixed |
Now |
Indeed twice as fast! Judging from a quick profile, the replaced The manpage for runc-checkpoint does not yet parse correctly. Possible fix: diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py
index ab5692f91..20237d628 100755
--- a/share/tools/create_manpage_completions.py
+++ b/share/tools/create_manpage_completions.py
@@ -519,3 +519,3 @@ class Type5ManParser(ManParser):
- options_section_regex = re.compile("\.SH OPTIONS(.*?)\.SH", re.DOTALL)
+ options_section_regex = re.compile("\.SH OPTIONS(.*?)(\.SH|$)", re.DOTALL)
@@ -1017,3 +1017,3 @@ def get_paths_from_man_locations(): runc-checkpoint(8).nh
.TH runc\-checkpoint "8"
.SH NAME
.PP
runc checkpoint \- checkpoint a running container
.SH SYNOPSIS
.PP
runc checkpoint [command options] \fB\fC<container\-id>\fR
.PP
Where "\fB\fC<container\-id>\fR" is the name for the instance of the container to be
checkpointed.
.SH DESCRIPTION
.PP
The checkpoint command saves the state of the container instance.
.SH OPTIONS
.PP
.RS
.nf
\-\-image\-path value path for saving criu image files
\-\-work\-path value path for saving work files and logs
\-\-parent\-path value path for previous criu image files in pre\-dump
\-\-leave\-running leave the process running after checkpointing
\-\-tcp\-established allow open tcp connections
\-\-ext\-unix\-sk allow external unix sockets
\-\-shell\-job allow shell jobs
\-\-lazy\-pages use userfaultfd to lazily restore memory pages
\-\-status\-fd value criu writes \\0 to this FD once lazy\-pages is ready
\-\-page\-server value ADDRESS:PORT of the page server
\-\-file\-locks handle file locks, for safety
\-\-pre\-dump dump container's memory information only, leave the container running after this
\-\-manage\-cgroups\-mode value cgroups mode: 'soft' (default), 'full' and 'strict'
\-\-empty\-ns value create a namespace, but don't restore its properties
\-\-auto\-dedup enable auto deduplication of memory images
.fi
.RE Also a quick 411toppm(1)\
.\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
.\" Do not hand-hack it! If you have bug fixes or improvements, please find
.\" the corresponding HTML page on the Netpbm website, generate a patch
.\" against that, and send it to the Netpbm maintainer.
.TH "411toppm User Manual" 0 "03 March 2001" "netpbm documentation"
.UN ixAAB
.UN lbAB
.SH NAME
411toppm - convert Sony Mavica .411 image to PPM
.UN lbAC
.SH SYNOPSIS
\fB411toppm\fP
[\fB-width \fP\fIwidth\fP]
[\fB-height \fP\fIheight\fP]
[\fI411file\fP]
.UN lbAD
.SH DESCRIPTION
.PP
This program is part of
.BR Netpbm (1)
.
.PP
\fB411toppm\fP reads a .411 file, such as from a Sony Mavic
camera, and converts it to a PPM image as output.
.PP
Output is to Standard Output.
.PP
The originator of this program and decipherer of the .411 format,
Steve Allen
<\fIsla@alumni.caltech.edu\fP>,
has this to say about the
utility of this program: 'There's so little image in a 64x48 thumbnail
(especially when you have the full size JPG file) that the only point
in doing this was to answer the implicit challenge posed by the manual
stating that only the camera can use these files.'
.UN lbAE
.SH OPTIONS
.PP
All options may be abbreviated to the shortest unique prefix.
.TP
\fB-width\fP
The width (number of columns) of the input image. Default is 64.
.TP
\fB-height\fP
The height (number of rows) of the input image. Default is 48.
.UN lbAF
.SH SEE ALSO
.BR ppm (5) Another thing: the
|
I'll look why it happens. |
It seems to work on my machine. Can you tell me on which man page does it happen? |
Ah sorry that was my bad, it failed because some of my local modifications. |
@krobelus Any other man pages that this PR breaks? |
Yeah, we are still losing some completions: $ rm -rf completions.old; mkdir completions.old; python share/tools/create_manpage_completions.py --manpath -d completions.old
$ rm -rf completions.new; mkdir completions.new; python share/tools/create_manpage_completions.py --manpath -d completions.new
$ diff -ru completions.{old,new} | grep -v '^.# using' | grep ^- | wc -l
10896
$ diff -ru completions.{old,new} | grep -v '^.# using' | grep ^+ | wc -l
3894 For example the completion for $ python share/tools/create_manpage_completions.py -s /usr/share/man/man1/acyclic.1.gz |
@krobelus Fixed, but I don't understand why it worked before. The only thing I've changed in |
Well that's awkward - I can confirm the We could fix the revived parsers. If you don't want to do this in this PR, then it's probably a good idea to explicitly disable them. We can always fix them later if needed. |
Yes, and most of them are
I think it's better to fix them now. |
No, it is hard. I'll disable |
I enabled
And new implementation (with
Counted with All of those 21 man pages are parsed correctly except |
Alright the type 5 ones that are made with It looks like removing type 2 somehow breaks the completions for ...
-complete -c fallocate -s c -l collapse-range -d 'Removes a byte range from a file, without leaving a hole'
-complete -c fallocate -s d -l dig-holes -d 'Detect and dig holes'
-complete -c fallocate -s i -l insert-range -d 'Insert a hole of length bytes from R offset , shifting existing data'
+complete -c fallocate -l collapse-range -l dig-holes -l punch-hole -d and
... Sadly, man pages are not standardized so trying to change the parsing is like opening a can of worms. I agree that the parser need not handle complicated formats but we should not generate worse completions for common man page formats. I'm sure we can find a solution that is an overall improvement. |
Yes, we can identify if man page was created by It would be so much better if man pages was standardized, and not just troff(?) documents. |
Now |
…rser This improves some generated completions, for example: diff -u completions.old/g3topbm.fish completions.new/g3topbm.fish +complete -c g3topbm -o stop_error -d 'This option tells g3topbm to fail when it finds a problem in the input' -complete -c g3topbm -o stop_error
…capable of parsing scdoc manpages This greatly improves generated completions for scdoc man pages, see #7187.
I reshuffled the commits to separate refactoring commits from behavior changes. Net diff below, most importantly:
Merging, thanks for this contribution! $ git diff -U0 3c52c7 aff2e7 -- share/tools/
diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py
index e90cefb59..97e48e49a 100755
--- a/share/tools/create_manpage_completions.py
+++ b/share/tools/create_manpage_completions.py
@@ -281 +281 @@ class Type1ManParser(ManParser):
- options_section = re.search(options_section_regex, manpage).group(0)
+ options_section = re.search(options_section_regex, manpage).group(1)
@@ -320 +319,0 @@ class Type1ManParser(ManParser):
- return True
@@ -394 +393 @@ class Type2ManParser(ManParser):
- options_section = re.search(options_section_regex, manpage).group(0)
+ options_section = re.search(options_section_regex, manpage).group(1)
@@ -425,2 +423,0 @@ class Type2ManParser(ManParser):
- return True
-
@@ -433 +430 @@ class Type3ManParser(ManParser):
- options_section = re.search(options_section_regex, manpage).group(0)
+ options_section = re.search(options_section_regex, manpage).group(1)
@@ -467,2 +463,0 @@ class Type3ManParser(ManParser):
- return True
-
@@ -476 +471 @@ class Type4ManParser(ManParser):
- options_section = re.search(options_section_regex, manpage).group(0)
+ options_section = re.search(options_section_regex, manpage).group(1)
@@ -510,4 +505 @@ class Type4ManParser(ManParser):
- return True
-
-# This parser works with and only with scdoc man pages
-class Type5ManParser(ManParser):
+class TypeScdocManParser(ManParser):
@@ -841 +833 @@ def parse_manpage_at_path(manpage_path, output_directory):
- Type5ManParser(),
+ TypeScdocManParser(),
@@ -880,2 +872,2 @@ def parse_manpage_at_path(manpage_path, output_directory):
- "\n# Autogenerated from man page " + manpage_path +
- "\n# using " + parser.__class__.__name__)
+ "\n# Autogenerated from man page " + manpage_path)
+ # built_command_output.insert(2, "# using " + parser.__class__.__name__) # XXX MISATTRIBUTES THE CULPABLE PARSER! Was really using Type2 but reporting TypeDeroffManParser |
So, if I get it right, without returning True many parses parse one man page and it does makes sense, except I mean without
|
Anyway, it all works now. Thanks for merging! |
The scdoc parser is meant to succeed, in that case we do want to |
Description
Some man pages (in my case
swappy(1)
) that was created withscdoc
had issues with autocompletion.Before
After
Affects
In my case man pages for those programms are now correctly parsed by
Type5ManParser
instead ofTypeDeroffManParser
:grim
,mako
,slurp
,sway
,swappy
,swaymsg
,swaynag
,speedtest-cli
and some moreBugs
Some autocompletions are not generated any more because previous logic was broken