Commit Graph

106 Commits

Author SHA1 Message Date
Augie Fackler
a2d8d347df minirst: look for column delimiters using slices instead of indicies
This works on both Python 2 and 3.
2017-05-28 15:47:43 -04:00
Augie Fackler
daa802d908 minirst: grab a byte, not an int, for the underline style 2017-05-28 13:36:02 -04:00
Augie Fackler
6fdf576b44 minirst: use bytes.strip instead of str.strip 2017-05-28 13:41:42 -04:00
Gregory Szorc
af6c4ae0b9 minirst: remove redundant _admonitions set
As Yuya pointed out during a review a month ago, _admonitions and
_admonitiontitles are largely redundant. With the last commit, they
are exactly redundant. So, remove _admonitions and use
_admonitiontitles.keys() instead.
2017-03-29 20:19:26 -07:00
Gregory Szorc
ceec73bcc5 minirst: remove "admonition" from _admonitions
The "admonition" rst primitive is split into "specific" admonitions
("attention," "caution," etc) and the "generic" admonition
("admonition"). For more, see
http://docutils.sourceforge.net/docs/ref/rst/directives.html#admonitions

The _admonitions set and keys of the _admonitiontitles dict
overlap exactly except _admonitions has an "admonition" entry.
Nowhere in Mercurial is the "admonition" admonition directive used.
Even if it were, it doesn't have a title, so it wouldn't be rendered
correctly.

So, let's remove "admonition" from the set of recognized admonition
directives.
2017-03-29 20:05:18 -07:00
Gregory Szorc
67bccc1d16 minirst: reindent _admonitiontitles
I don't like the verical indent.

While I was here, I cleaned up some whitespace and added a trailing
comma on the last element.
2017-03-29 19:59:47 -07:00
Pulkit Goyal
f34f53b9de minirst: use bytes.strip instead of str.strip
bytes.strip exists in Python 2.6 and Python 2.7 also.
2017-03-12 22:46:57 +05:30
Pulkit Goyal
077cba9952 minirst: make encoding.encoding unicodes to pass into encode() and decode() 2017-03-12 07:09:18 +05:30
Pulkit Goyal
bd7d2c3f64 minirst: make regular expressions bytes 2017-03-12 06:59:37 +05:30
Gregory Szorc
178fc087aa minirst: support passing admonitions into findadmonitions() and parse()
This will allow consumers to declare a custom list of admonitions
to parse. Without this patch, custom admonitions would get removed
when prunecomments() is run. We could add an argument controlling
whether prunecomments() is run. However, it is better to convert
the "paragraph" block to an "admonition" block so consumers don't
have to parse for custom admonitions.
2017-02-15 11:49:12 -08:00
Gregory Szorc
006ef6abfb minirst: dynamically compile admonitions regexp
Currently, parsing admonitions uses a static regular expression created
from a pre-defined list of admonitions. A future patch will introduce a
feature that needs to parse custom admonitions. Prepare for this by
compiling the admonitions regular expression during each function
invocation.

Strictly speaking, there is a slight performance loss here. But we only
run this code as part of displaying help text. I don't think the loss
will be noticeable and I don't think we care if it were.
2017-02-15 11:47:14 -08:00
Gregory Szorc
0f0aba8e06 minirst: detect bullet lists using asterisks
Previously, the "bullet" regular expression excluded the asterisk
('*') as a character denoting a bulleted list. Why I'm not sure
because the asterisk seems to be the canonical bullet character
in reST these days.

This patch makes asterisk-prefixed lines parse as bulleted lists.
2017-02-15 16:42:17 -08:00
Augie Fackler
08c942eef2 minirst: avoid shadowing a variable in a list comprehension 2016-11-10 16:33:41 -05:00
FUJIWARA Katsunori
17fa5d0520 help: search section of help topic by translated section name correctly
Before this patch, "hg help topic.section" might show unexpected
section of help topic in some encoding.

It applies str.lower() instead of encoding.lower(str) on translated
message to search section case-insensitively, but some encoding uses
0x41(A) - 0x5a(Z) as the second or later byte of multi-byte character
(for example, ja_JP.cp932), and str.lower() causes unexpected result.

To search section of help topic by translated section name correctly,
this patch replaces str.lower() by encoding.lower(str) for both query
string (in commands.help()) and translated help text (in
minirst.getsections()).
2016-05-13 07:19:59 +09:00
timeless
45b895c57d minirst: change hgrole to use single quotes
We decided to reserve double quotes for arguments to hg because cmd
does not like single quotes, so switch the outer quotes to single
2016-01-12 06:03:36 +00:00
timeless
c09ee5764f help: include section heading if section depth changes
This makes it easier to distinguish between:

"format"
--------
"usestore"
...
    Enabled by default.

and

"progress.format"
    Format of the progress bar.
2016-01-01 16:59:13 +00:00
Mads Kiilerich
09567db49a spelling: trivial spell checking 2015-10-17 00:58:46 +02:00
Matt Mackall
5e1b4ad958 urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
timeless@mozdev.org
ea3920eaa0 minirst: establish leveling for nested definitions 2015-09-10 10:48:20 -04:00
timeless@mozdev.org
d58a9315b3 minirst: handle edge in hunting for parents
test for "hg help -c config" in help config

``section``
-----------
section text

``def1``
    definition of def1
    $ hg help scope.def1
    should list this paragraph, but not section text below...

section text

``def2``
    definition of def2
    $ hg help scope.def2
    should list this paragraph, but not section text below...

section text
$ hg help scope.section should show everything from the first
section text to this last line.

``section2``
------------
2015-09-03 17:06:27 -04:00
timeless@mozdev.org
f9b3b64087 minirst: don't treat top level item as children of last item (issue4803)
test for "hg help -c config" in help config
2015-09-02 15:12:08 -04:00
timeless@mozdev.org
3a5cdbfaac help: distinguish sections when multiple match (issue4802) 2015-08-30 19:03:38 -04:00
Gregory Szorc
77d714a7aa minirst: use absolute_import 2015-08-08 19:42:16 -07:00
Matt Harbison
1ea0ae2f3c help: support 'hg help template.somekeyword'
Previously the output was simply 'abort: help section not found'.
2015-07-04 23:11:32 -04:00
Jordi Gutiérrez Hermoso
cea41a20fd help: show all nested subsections of a section with hg help foo.section
Used to be that `hg help hgrc.paths` would show

    "paths"
    -------

    Assigns symbolic names to repositories. The left side is the symbolic
    name, and the right gives the directory or URL that is the location of the
    repository. Default paths can be declared by setting the following
    entries.

and stop there. Obviously the result seems better as shown in the
attached test.
2014-10-06 07:35:53 -04:00
Jordi Gutiérrez Hermoso
76e10f34d1 help: fix output of sections in hg help foo.somesection
There was a bug in df3ceb2fbb4d. The block that added definitions to
getsections should have been an elif, not an if. Otherwise section
titles get added twice, since the else clause would always get
executed for section titles.
2014-10-06 07:29:38 -04:00
Matt Mackall
e5c9cc0aaf help: basic support for showing only specified topic sections
For instance, 'hg help config.files' will show only the Files section.
2014-09-30 16:40:10 -05:00
Matt Mackall
0b131abaec minirst: allow multiple container types for prune
If we have a container of type x.y, then we can preserve it by
keeping x or y.
2014-09-30 15:48:43 -05:00
Matt Mackall
ceb82a6112 minirst: explicitly decode substitutions
Caught by Augie and sys.setdefaultencoding("undefined")
2014-06-13 14:14:02 -05:00
Augie Fackler
7457cb9d81 minirst: move from dict() construction to {} literals
The latter are both faster and more consistent across Python 2 and 3.
2014-03-12 13:20:24 -04:00
Simon Heimberg
0aad267371 minirst: create valid output when table data contains a newline
When table data contained a newline, the result of minirst.maketable
did not look nice plus it was not recognised by minirst.format:
  == === ====
  l1 1   one
  l2 2   2
22
  l3
  == === ====

This problem occurred when the description of options had a very long
translation which was split by newlines. Do not bother a translator with
this detail.

The multiline translations for option descriptions have been fixed in
7a88a81d5d9e in it.po, de.po and ro.po. I manually did the same as this patch
does, I removed the newlines.

When a newline was in the description, this created unusable help output:
  $ hg help somecommand
  hg somecommand [option]...

  with somecommand, you can...

  options:

  == =================== =======================================================
  =================================== --longdesc VALUE    xxxxxxxxxxxxxxxxxxxxxx
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -n --norm
  normal desc --newline VALUE line1 line2 == =================== ===============
  ===========================================================================

now this looks much nicer:
  ...
  options:

      --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                       xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   -n --norm           normal desc
      --newline VALUE  line1 line2
2014-02-19 17:32:21 +01:00
Mads Kiilerich
92dc407d90 comments: fix minor spelling issues found with spell checker 2014-02-20 02:39:01 +01:00
Simon Heimberg
386dcc916f minirst: do not add a 2nd empty paragraph
This does not add a separating block after a separated note directive.

.. note::

    text

is formatted to

Note:
    text
2013-11-04 10:23:06 +01:00
Simon Heimberg
664e8c41fe minirst: find admonitions before pruning comments and adding margins
Lines with only a directive are not deleted anymore because they are detected
before comments are deleted by prunecomments().
addmargins() will be adapted later.
2013-11-04 10:23:06 +01:00
Simon Heimberg
c5557c2259 minirst: do not fail on an empty admonition block 2013-11-04 10:23:06 +01:00
Simon Heimberg
0e05d277a4 minirst: do not interpret a directive as a literal block
When a directive was on its own line, it was interpreted as a literal block.

Example of problematic input:

.. note::

    a note text
2013-11-04 10:23:06 +01:00
Dan Villiom Podlaski Christiansen
17ccef70f8 minirst: optimize HTML table generation a bit
avoid a couple of array copies and string interpolations
2013-02-09 21:51:21 +00:00
Dan Villiom Podlaski Christiansen
e6781fbadb minirst: HTML formatter tweaks
output table rows on distinct lines
don't make the first row a table header
2013-02-09 21:51:21 +00:00
Dan Villiom Podlaski Christiansen
5ff9149ead minirst: CGI escape strings prior to embedding it in the HTML 2013-02-09 17:44:25 -05:00
Dan Villiom Podlaski Christiansen
768b2c3969 minirst: don't generate TH elements for the first row in table
We mainly use them for option tables -- browsers bolding and centering
them looks wrong.
2013-02-09 21:51:21 +00: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
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Olav Reinert
70c42374e2 minirst: generate tables as a list of joined lines 2012-06-01 11:58:23 +02:00
Olav Reinert
cfc7a5074e minirst: simplify and standardize field list formatting
The default width of field lists is changed from 12 to 14 to align minirst with
the rst2html tool. Shrinking the width of the left column to fit the content is
removed, to keep formatting simple and uniform.
2012-01-11 18:08:25 +01:00
FUJIWARA Katsunori
f6b7a91d98 minirst: use unicode string as intermediate form for replacement
# this change redones part of e0051068893a, backed out by 38c00c035629

Some character encodings use ASCII characters other than
control/alphabet/digit as a part of multi-bytes characters, so direct
replacing with such characters on strings in local encoding causes
invalid byte sequences.

[mpm: test changed to simple doctest]
2011-10-31 21:06:18 +09:00
Matt Mackall
7791d14df5 minirst: add style flag to format 2011-10-15 00:39:04 -05:00
Matt Mackall
cdd258d4fd minirst: add basic HTML formatting support 2011-10-15 00:39:01 -05:00
Matt Mackall
2a412dcdd8 rst: fix detection of single-row tables
This fixes option lists for commands with only an --mq option.
2011-10-02 13:13:46 -05:00
Matt Mackall
4204f3ffa5 help: use RST to format option lists 2011-09-21 13:00:48 -05:00
Matt Mackall
52b9791173 minirst: fix column handling for simple tables 2011-09-21 13:00:47 -05:00