Commit Graph

61 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
f46b49a0e3 check-code: detect "missing _() in ui message" more exactly
Before this patch, "missing _() in ui message" rule overlooks
translatable message, which starts with other than alphabet.

To detect "missing _() in ui message" more exactly, this patch
improves the regexp with assumptions below.

  - sequence consisting of below might precede "translatable message"
    in same string token

    - formatting string, which starts with '%'
    - escaped character, which starts with 'b' (as replacement of '\\'), or
    - characters other than '%', 'b' and 'x' (as replacement of alphabet)

  - any string tokens might precede a string token, which contains
    "translatable message"

This patch builds an input file, which is used to examine "missing _()
in ui message" detection, before '"$check_code" stringjoin.py' in
test-contrib-check-code.t, because this reduces amount of change churn
in subsequent patch.

This patch also applies "()" instead of "_()" on messages below to
hide false-positives:

  - messages for ui.debug() or debug commands/tools
    - contrib/debugshell.py
    - hgext/win32mbcs.py (ui.write() is used, though)
    - mercurial/commands.py
      - _debugchangegroup
      - debugindex
      - debuglocks
      - debugrevlog
      - debugrevspec
      - debugtemplate

  - untranslatable messages
    - doc/gendoc.py (ReST specific text)
    - hgext/hgk.py (permission string)
    - hgext/keyword.py (text written into configuration file)
    - mercurial/cmdutil.py (formatting strings for JSON)
2016-06-21 00:50:39 +09:00
Sean Farley
dc865d7f73 hg-ssh: copy doc string to man page
This corrects a warning from lintian that we're shipping an executable without
a man page. Since there is a doc string in the text, let's use that for the man
page.
2016-05-06 23:03:41 -07:00
Pulkit Goyal
e736fa4f52 py3: make gendoc use absolute_import
Fixed direct imports even the tests were not complaining.
2016-04-17 00:20:44 +05:30
Jun Wu
ea41b32b83 mercurial: pass ui to extensions.load (issue5007)
extensions.load does need ui argument to print error if an extension
fails to load.
2015-12-17 10:30:17 +00:00
timeless
b7fa6a1a27 doc: add execute bit and fix shbang line for gendoc.py 2015-12-22 07:59:14 +00:00
Gregory Szorc
b6d0b58fa7 doc: make gendoc.py module import policy aware
Without this, running gendoc.py during an install without C modules
available (via `make local`) will result in an import failure because
the default module load policy insists on C modules.

We also remove the sys.path adjustment because it is no longer needed
since our magic importer handles things.
2015-12-12 13:23:29 -05:00
Yuya Nishihara
2f746aa9d3 help: pass around ui to doc loader (API)
This is necessary to hide DEPRECATED items conditionally.

Flagged as API change because it will break "hg help git|subversion".
2015-09-26 12:06:30 +09:00
Yuya Nishihara
958a6389af gendoc: use real ui in place of stdout
ui attributes will be required by a help function, so a file object can't be
used as a fake ui.
2015-09-27 23:34:37 +09:00
Augie Fackler
9f565e54cb gendoc: restore use of callable() since it was readded in Python 3.2 2014-06-23 09:23:57 -04:00
FUJIWARA Katsunori
138416bff7 doc: show short description of each commands in generated documents
Before this patch, short description of each commands is not shown in
generated documents (HTML file and UNIX man page). This omitting may
prevent users from understanding about commands.

This patch show it as the 1st paragraph in the help section of each
commands. This style is chosen because:

  - showing it as the section title in "command - short desc" style
    disallows referencing by "#command" in HTML file: in "en" locale,
    hyphen concatenated title is used as the section ID in HTML file
    for this style

  - showing it as the 1st paragraph in "command - short desc" style
    seems to be redundant: "command" appears also just before as the
    section title

  - showing it just after synopsis like "hg help command" seems not to
    be reasonable in UNIX man page

This patch just writes short description ("d['desc'][0]") before "::",
because it should be already "strip()"-ed in "get_desc()", or empty
string for the command without description.
2014-03-11 14:36:40 +09:00
Simon Heimberg
ff9aaaba6b doc: gendoc.py creates valid output for option descriptions with newlines
gendoc.py did not handle the hanging indentation for descriptions. Work around
this by joining all in one single line (same as in minirst since previous
patch).

This problem occurred when translations of option lines were very long. Do not
bother the translators with this detail.

On a long option description, the translator continued on a new line as usual.
gendoc.py created invalid rst syntax like this:

-o, --option
    Description line 1
description line 2

The new output is:

-o, --option
    Description line 1 description line 2

The lines could theoretically become very long, but line breaking is handled
when generating the final documentation.
2014-02-20 09:17:22 +01:00
FUJIWARA Katsunori
8c1c74a873 doc: show details of command options in pages generated by docutils
Before this patch, HTML/man pages generated by docutils don't show
details of each command options, whether it should take argument or
not for example, even though "hg help" does.

This patch shows details of command options as same as "hg help"
shows.

This patch uses "--option <VALUE[+]>" style instead of "--option
<VALUE> [+]" used in output of "hg help", because docutils requires
that option argument strings starts with "<" and ends with ">".
2013-11-08 14:42:09 +09:00
Takumi IINO
4e9e5e1a97 gendoc: dispatch print document content by commandline arguments
Before this patch, gendoc.py only prints hg.1.gendoc.txt content.
This adds any content print function.
2013-07-03 21:49:41 +09:00
Takumi IINO
aa35bddf6e gendoc: add showtopic
This function prints any topic.
2013-07-03 21:49:39 +09:00
Takumi IINO
6a0123c5c5 gendoc: rename to showdoc from show_doc
This function prints hg.1.gendoc.txt content.
2013-07-03 21:49:37 +09:00
Simon Heimberg
8a32578a00 cleanup: remove unused imports
detected by pyflakes
2013-06-13 01:36:58 +02:00
Takumi IINO
b0aea72ba7 gendoc: extract print help topics into a dedicated function
This will be used in an upcoming patch.
2013-05-15 15:44:59 +09:00
Takumi IINO
9b959d84eb gendoc: make commnd __doc__ and extension __doc__ as translatable
Before this patch, commnd __doc__ and extension __doc__ are not translatable.
But other messages, like doc of helptalbe, section headers, are translatable.

This patch makes commnd __doc__ and extension __doc__ translatable.
2013-05-15 15:44:55 +09:00
Dan Villiom Podlaski Christiansen
d045d03b91 help: use a full header for topic titles
...for prettier HTML!
2013-02-10 12:58:57 +01:00
FUJIWARA Katsunori
0cf97588a4 doc: unify section level between help topics
Some help topics use "-" for the top level underlining section mark,
but "-" is used also for the top level categorization in generated
documents: "hg.1.html", for example.

So, TOC in such documents contain "sections in each topics", too.

This patch changes underlining section mark in some help topics to
unify section level in generated documents.

After this patching, levels of each section marks are:

  level0
  """"""
    level1
    ======
      level2
      ------
        level3
        ......
          level4
          ######

And use of section markers in each documents are:

  - mercurial/help/*.txt can use level1 or more
    (now these use level1 and level2)

  - help for core commands can use level2 or more
    (now these use no section marker)

  - descriptions of extensions can use level2 or more
    (now hgext/acl uses level2)

  - help for commands defined in extension can use level4 or more
    (now "convert" of hgext/convert uses level4)

"Level0" is used as top level categorization only in "doc/hg.1.txt"
and the intermediate file generated by "doc/gendoc.py", so end users
don't see it in "hg help" outoput and so on.
2012-07-25 16:40:38 +09:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Augie Fackler
fdd2f9d735 globally: use safehasattr(x, '__call__') instead of hasattr(x, '__call__') 2011-07-25 16:24:37 -05:00
Martin Geisler
9573c538b1 gendoc: config help topic is in hgrc.5, do not include it in hg.1 2011-05-30 11:18:47 +02:00
Matt Mackall
d184ed2af2 extensions: drop maxlength from enabled and disabled
This is a bad/silly API. Instead calculate maxlength in one place in help
it's used and simplify all the callers.
2011-05-13 11:04:51 -05:00
Javi Merino
aadbeeda71 doc: Capitalize the "options" header of mercurial commands 2011-02-05 14:37:25 +00:00
Thomas Arendsen Hein
16ae1c2ebb coding style: fix yield used as a function 2010-12-03 12:22:56 +01:00
Martin Geisler
63ce42a571 gendoc: do not strip 'hg ' from synopsis
This was an old left-over from when the synopsis line was used as a
header. We now have the command name by itself as the header and the
synopsis as a literal block immediately after..
2010-10-23 00:18:10 +02:00
Martin Geisler
526cbba402 gendoc: support multi-line synopses 2010-10-23 00:11:39 +02:00
Martin Geisler
fc7340c8f7 gendoc: re-add indentation to global option table
The indentation was lost in 5a8c9ce7fb90.
2010-10-23 00:01:09 +02:00
Martin Geisler
7e2dd66daa merge-tools: fixed typos
Spotted by Patrick Mézard.
2010-10-21 21:34:30 +02:00
Erik Zielke
efadd693cc gendoc: automatically create help for default extensions.
Adds a section in the hg.1 manpage and corresponding hg.1.html
file. Each extension is listed with its module docstring, followed by
the commands defined by that extendsion.

Creates help for extensions by extracting doc strings from the extension modules
and its commands.
2010-10-20 17:45:09 +02:00
Erik Zielke
6a81d064ce gendoc: dedent documentation from docstrings
When getting docstrings from the source they are indented to look good
in the code. This indentation interferes with how the text is parsed
by rst. Therefore this indentation is removed.
2010-10-19 13:50:03 +02:00
Martin Geisler
d6c5b6360c gendoc: add subsection for each command 2010-10-20 18:08:37 +02:00
Martin Geisler
6cbb755d15 gendoc: move section commands to module scope 2010-10-20 18:07:50 +02:00
Erik Zielke
b55d97e2ae gendoc: refactor get_cmd
Refactors the get_cmd to take the table as argument, instad
of just referencing the global table, thereby enabling reuse
for extension command tables.
2010-10-18 14:37:52 +02:00
Martin Geisler
bf3b3f3285 gendoc: remove call to callable for py3k compatibility 2010-07-15 14:02:17 +02:00
FUJIWARA Katsunori
ce06b102df help: show value requirement and multiple occurrence of options
this helps users to know what kind of option is:

  - no value is required(flag option)
  - value is required
  - value is required, and multiple occurrences are allowed

each kinds are shown as below:

 -f --force              force push
 -e --ssh CMD            specify ssh command to use
 -b --branch BRANCH [+]  a specific branch you would like to push

if one or more 3rd type options are shown, explanation for '[+]' mark
is also shown as footnote.
2010-06-06 17:25:00 +09:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Martin Geisler
e2d8b0b8e1 doc: use titlecase in man page section titles 2009-11-08 11:46:38 +01:00
Martin Geisler
7411f95959 gendoc: fix synopsis
The synopsis is used as an inline literal when generating the manpage.
There should not be any whitespace on the inside of the quotation
marks in inline literals.

Commands with an empty synopsis (such as tags) produces ``tags `` as
synopsis, which triggers a warning.
2009-10-20 22:42:49 +02:00
Martin Geisler
1d1318a176 test-gendoc: add tests for all languages
This ensures that we catch errors in the reST syntax early and for all
languages. The only change needed in gendoc.py was to correct the
computation of section underlines for Asian languages.
2009-09-27 10:12:02 +02:00
Martin Geisler
7b90d8d58a gendoc: do not wrap encoded string
- it breaks multi-byte characters
- it is not needed since Docutils will take care of wrapping the
  strings as necessary
2009-09-27 10:04:51 +02:00
Dirkjan Ochtman
567b1cc6eb Backed out changeset e07e58e3faab (depends on other changes, no tests) 2009-08-05 16:32:38 +02:00
Cédric Duval
2b3b3cf99a gendoc: documentation section describing available extensions 2009-08-05 14:44:36 +02:00
Martin Geisler
fcc8159264 gendoc: make anchors for help topic names 2009-08-02 17:42:36 +02:00
Martin Geisler
b9abfaca93 gendoc: rename underlined/bold to section/subsection 2009-07-31 11:40:03 +02:00
Martin Geisler
7b2133abae Merge with crew-stable 2009-07-24 15:28:29 +02:00
Cédric Duval
5f07139d53 gendoc: don't translate topic strings twice (issue1760) 2009-07-24 12:20:40 +02:00
Martin Geisler
92882a99d0 doc: use reStructuredText for man and HTML pages
The Makefile now requires the rst2html and rst2man programs. Both can
be found in Debian testing or downloaded from the Docutils homepage:

  http://docutils.sf.net/
  http://docutils.sf.net/sandbox/manpage-writer/

The new HTML and man pages no longer contain huge amounts of
un-wrapping literal blocks, thanks to how snippets of reStructuredText
can easily be included inside other reStructuredText documents.

The HTML pages now have anchors for all sections, including the help
topics in hgrc.1 which were missing from the old HTML pages.
2009-07-16 23:25:26 +02:00
Cédric Duval
ba6555759d gendoc: fall back to pure modules if C extensions are not available (issue1711) 2009-07-10 19:45:31 +02:00