[GRASS-dev] [GRASS GIS] #3975: g.manual -m gives ERROR: No manual page entry

#3975: g.manual -m gives ERROR: No manual page entry
-------------------------+-------------------------
Reporter: jidanni | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Docs | Version: unspecified
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
man xyz works.
g.manual xyz works.
g.manual -m xyz says ERROR: No manual page entry for xyz.
At least here on Debian sid.
{{{
GRASS 7.8.1 (newLocation):~ > g.manual -m g.manual
ERROR: No manual page entry for 'g.manual'
GRASS 7.8.1 (newLocation):~ > g.manual -m d.vect
ERROR: No manual page entry for 'd.vect'
GRASS 7.8.1 (newLocation):~ > g.manual -i
GRASS 7.8.1 (newLocation):~ > g.manual -i -m
ERROR: No manual page entry for 'index'
GRASS 7.8.1 (newLocation):~ > g.manual -t -m
ERROR: No manual page entry for 'topics'
GRASS 7.8.1 (newLocation):~ > g.manual g.manual
GRASS 7.8.1 (newLocation):~ >
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3975&gt;
GRASS GIS <https://grass.osgeo.org>

#3975: g.manual -m gives ERROR: No manual page entry
--------------------------+---------------------------------
  Reporter: jidanni | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.2
Component: Docs | Version: git-releasebranch78
Resolution: | Keywords: Debian
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Changes (by neteler):

* keywords: => Debian
* version: unspecified => git-releasebranch78
* milestone: => 7.8.2

Comment:

Works nicely on Fedora:

{{{
g.manual -m g.manual

g.manual(1) Grass User's
Manual g.manual(1)

NAME
        g.manual - Displays the manual pages of GRASS modules.

KEYWORDS
        general, manual, help
...
}}}

The manual pages are expected to be under

/usr/lib64/grass78/docs/man/man1/x.yyy.1

see path in
https://github.com/OSGeo/grass/blob/master/scripts/g.manual/g.manual.py#L101

Perhaps stores the MAN pages elsewhere?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3975#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3975: g.manual -m gives ERROR: No manual page entry
--------------------------+---------------------------------
  Reporter: jidanni | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.2
Component: Docs | Version: git-releasebranch78
Resolution: | Keywords: Debian
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by Bas Couwenberg):

Manpages have the 'grass' suffix appended to the section to prevent
conflicts, see:

  https://salsa.debian.org/debian-gis-
team/grass/blob/debian/7.8.1-1/debian/rules#L150

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3975#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3975: g.manual -m gives ERROR: No manual page entry
--------------------------+---------------------------------
  Reporter: jidanni | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.2
Component: Docs | Version: git-releasebranch78
Resolution: | Keywords: Debian
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by neteler):

Replying to [comment:2 Bas Couwenberg]:
> Manpages have the 'grass' suffix appended to the section to prevent
conflicts, see:
>
> https://salsa.debian.org/debian-gis-
team/grass/blob/debian/7.8.1-1/debian/rules#L150

I see a "grass7.1" in the line
https://salsa.debian.org/debian-gis-
team/grass/blob/debian/7.8.1-1/debian/rules#L151

maybe that's the problem?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3975#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>

#3975: g.manual -m gives ERROR: No manual page entry
--------------------------+---------------------------------
  Reporter: jidanni | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.2
Component: Docs | Version: git-releasebranch78
Resolution: | Keywords: Debian
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by Bas Couwenberg):

> maybe that's the problem?

No, that just renames `grass7.1` to `grass78.1`.

> The manual pages are expected to be under
> /usr/lib64/grass78/docs/man/man1/x.yyy.1

Which is not the case on Debian:
{{{
$ apt-file search man1/g.manual.1
grass-doc: /usr/share/man/man1/g.manual.1grass.gz
}}}

So `g.manual.py` needs to be patched to test the `.1grass` section suffix
instead of just `.1`, this is more in line with what `man(1)` does, as it
has no issue to find manpages with `.1foo` suffixes:
{{{
$ man -w g.manual
/usr/share/man/man1/g.manual.1grass.gz
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3975#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#3975: g.manual -m gives ERROR: No manual page entry
--------------------------+---------------------------------
  Reporter: jidanni | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.2
Component: Docs | Version: git-releasebranch78
Resolution: | Keywords: Debian
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by Bas Couwenberg):

Something like this may be a good solution:
{{{
--- a/g.manual 2019-11-18 20:06:17.402073322 +0100
+++ b/g.manual 2019-11-18 20:16:03.794093319 +0100
@@ -46,6 +46,7 @@
  #% required : yes
  #%end

+import subprocess
  import sys
  import os

@@ -98,6 +99,19 @@

  def start_man(entry):
+ try:
+ cmd = ['man', '-w', '1', entry]
+
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ (stdout, stderr) = process.communicate()
+
+ paths = stdout.decode().split('\n')
+
+ if os.path.exists(paths[0]):
+ os.execlp('man', 'man', paths[0])
+ except Exception:
+ pass
+
      path = os.path.join(gisbase, 'docs', 'man', 'man1', entry + '.1')
      if not os.path.exists(path) and os.getenv('GRASS_ADDON_BASE'):
          path = os.path.join(os.getenv('GRASS_ADDON_BASE'), 'docs', 'man',
'man1', entry + '.1')
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3975#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>