Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/m2r/files/, dev-python/m2r/
Date: Fri, 31 Mar 2017 21:11:30
Message-Id: 1490994531.e8d6dbf2b8657c9e5f695c4e663b6d862ed46e87.dolsen@gentoo
1 commit: e8d6dbf2b8657c9e5f695c4e663b6d862ed46e87
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Fri Mar 31 00:57:47 2017 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Fri Mar 31 21:08:51 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e8d6dbf2
7
8 dev-python/m2r: New package, dep of dev-python/automat
9
10 Package-Manager: Portage-2.3.5, Repoman-2.3.2_p30
11
12 dev-python/m2r/Manifest | 1 +
13 dev-python/m2r/files/m2r.1 | 515 ++++++++++++++++++++++++++++++++++++++++
14 dev-python/m2r/files/test.md | 5 +
15 dev-python/m2r/files/test.rst | 8 +
16 dev-python/m2r/m2r-0.1.5.ebuild | 50 ++++
17 dev-python/m2r/metadata.xml | 19 ++
18 6 files changed, 598 insertions(+)
19
20 diff --git a/dev-python/m2r/Manifest b/dev-python/m2r/Manifest
21 new file mode 100644
22 index 00000000000..721b61b97fc
23 --- /dev/null
24 +++ b/dev-python/m2r/Manifest
25 @@ -0,0 +1 @@
26 +DIST m2r-0.1.5.tar.gz 13202 SHA256 3448f770aed05ca10390d0917cd51836cbf82a2f095bc91507e6291cfab03223 SHA512 78e9e8daa293b2466c95f0adad937fa0bbefaf0dd9663695bb916be13182633e0d462afa5331a595db424420485ef54bbfd4e0625962026fab4ce0c63104bc84 WHIRLPOOL c701aa0a735eda9b7eaab7ff6f384bad7535337f6a7adcfce2d729f33b01aed9213d04fcfe1dc3521b2df0687f2b849a3eb5df628a87ea3ea2697ae389ad8438
27
28 diff --git a/dev-python/m2r/files/m2r.1 b/dev-python/m2r/files/m2r.1
29 new file mode 100644
30 index 00000000000..1a6c10b48a9
31 --- /dev/null
32 +++ b/dev-python/m2r/files/m2r.1
33 @@ -0,0 +1,515 @@
34 +.\" Man page generated from reStructuredText.
35 +.
36 +.TH "M2R" "1" "Mar 30, 2017" "0.1.5" "M2R"
37 +.SH NAME
38 +m2r \- M2R Documentation
39 +.
40 +.nr rst2man-indent-level 0
41 +.
42 +.de1 rstReportMargin
43 +\\$1 \\n[an-margin]
44 +level \\n[rst2man-indent-level]
45 +level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
46 +-
47 +\\n[rst2man-indent0]
48 +\\n[rst2man-indent1]
49 +\\n[rst2man-indent2]
50 +..
51 +.de1 INDENT
52 +.\" .rstReportMargin pre:
53 +. RS \\$1
54 +. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
55 +. nr rst2man-indent-level +1
56 +.\" .rstReportMargin post:
57 +..
58 +.de UNINDENT
59 +. RE
60 +.\" indent \\n[an-margin]
61 +.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
62 +.nr rst2man-indent-level -1
63 +.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
64 +.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
65 +..
66 +\fI\%PyPI\fP\fI\%PyPI version\fP\fI\%Build Status\fP\fI\%codecov\fP
67 +.sp
68 +.ce
69 +----
70 +
71 +.ce 0
72 +.sp
73 +.sp
74 +M2R converts a markdown file including reST markups to a valid reST format.
75 +.SH WHY ANOTHER CONVERTER?
76 +.sp
77 +I wanted to write sphinx document in markdown, since it\(aqs widely used now and
78 +easy to write code blocks and lists. However, converters using pandoc or
79 +recommonmark do not support many reST markups and sphinx extensions. For
80 +example, reST\(aqs reference link like \fBsee \(garef\(ga_\fP (this is very convenient in
81 +long document in which same link appears multiple times) will be converted to
82 +a code block in HTML like \fBsee <code>ref</code>_\fP, which is not expected.
83 +.SH FEATURES
84 +.INDENT 0.0
85 +.IP \(bu 2
86 +Basic markdown and some extensions (see below)
87 +.INDENT 2.0
88 +.IP \(bu 2
89 +inline/block\-level raw html
90 +.IP \(bu 2
91 +fenced\-code block
92 +.IP \(bu 2
93 +tables
94 +.IP \(bu 2
95 +footnotes (\fB[^1]\fP)
96 +.UNINDENT
97 +.IP \(bu 2
98 +Inline\- and Block\-level reST markups
99 +.INDENT 2.0
100 +.IP \(bu 2
101 +single\- and multi\-line directives (\fB\&.. directive::\fP)
102 +.IP \(bu 2
103 +inline\-roles (\fB:code:\(gaprint(1)\(ga ...\fP)
104 +.IP \(bu 2
105 +ref\-link (\fBsee \(garef\(ga_\fP)
106 +.IP \(bu 2
107 +footnotes (\fB[#fn]_\fP)
108 +.IP \(bu 2
109 +math extension inspired by \fI\%recommonmark\fP
110 +.UNINDENT
111 +.IP \(bu 2
112 +Sphinx extension
113 +.INDENT 2.0
114 +.IP \(bu 2
115 +add markdown support for sphinx
116 +.IP \(bu 2
117 +\fBmdinclude\fP directive to include markdown from md or reST files
118 +.UNINDENT
119 +.UNINDENT
120 +.SH INSTALLATION
121 +.sp
122 +Python 2.7 or Python 3.3+ is required.
123 +.INDENT 0.0
124 +.INDENT 3.5
125 +.sp
126 +.nf
127 +.ft C
128 +pip install m2r
129 +.ft P
130 +.fi
131 +.UNINDENT
132 +.UNINDENT
133 +.SH USAGE
134 +.SS Command Line
135 +.sp
136 +\fBm2r\fP command converts markdown file to reST format.
137 +.INDENT 0.0
138 +.INDENT 3.5
139 +.sp
140 +.nf
141 +.ft C
142 +m2r your_document.md [your_document2.md ...]
143 +.ft P
144 +.fi
145 +.UNINDENT
146 +.UNINDENT
147 +.sp
148 +Then you will find \fByour_document.rst\fP in the same directory.
149 +.SS Programmatic Use
150 +.sp
151 +Instantiate \fBM2R\fP class and call with markdown text. Then it will return converted text.
152 +.INDENT 0.0
153 +.INDENT 3.5
154 +.sp
155 +.nf
156 +.ft C
157 +from m2r import M2R
158 +m2r = M2R()
159 +rest = m2r(\(aq# Title\en\enSentence.\(aq)
160 +print(rest)
161 +# Title
162 +# =====
163 +#
164 +# Sentence.
165 +.ft P
166 +.fi
167 +.UNINDENT
168 +.UNINDENT
169 +.sp
170 +Or, use \fBparse_from_file\fP function to load markdown file and obtain converted text.
171 +.INDENT 0.0
172 +.INDENT 3.5
173 +.sp
174 +.nf
175 +.ft C
176 +from m2r import parse_from_file
177 +output = parse_from_file(\(aqmarkdown_file.md\(aq)
178 +.ft P
179 +.fi
180 +.UNINDENT
181 +.UNINDENT
182 +.sp
183 +This is an example of setup.py to write README in markdown, and publish it to PyPI as reST format.
184 +.INDENT 0.0
185 +.INDENT 3.5
186 +.sp
187 +.nf
188 +.ft C
189 +readme_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), \(aqREADME.md\(aq)
190 +try:
191 + from m2r import parse_from_file
192 + readme = parse_from_file(readme_file)
193 +except ImportError:
194 + # m2r may not be installed in user environment
195 + with open(readme_file) as f:
196 + readme = f.read()
197 +setup(
198 + ...,
199 + long_description=readme,
200 + ...,
201 +)
202 +.ft P
203 +.fi
204 +.UNINDENT
205 +.UNINDENT
206 +.SS Sphinx Integration
207 +.sp
208 +In your conf.py, add the following lines.
209 +.INDENT 0.0
210 +.INDENT 3.5
211 +.sp
212 +.nf
213 +.ft C
214 +extensions = [
215 + ...,
216 + \(aqm2r\(aq,
217 +]
218 +
219 +# source_suffix = \(aq.rst\(aq
220 +source_suffix = [\(aq.rst\(aq, \(aq.md\(aq]
221 +.ft P
222 +.fi
223 +.UNINDENT
224 +.UNINDENT
225 +.sp
226 +Write index.md and run \fBmake html\fP\&.
227 +.sp
228 +When \fBm2r\fP extension is enabled on sphinx and \fB\&.md\fP file is loaded, m2r
229 +converts to reST and pass to sphinx, not making new \fB\&.rst\fP file.
230 +.SS mdinclude directive
231 +.sp
232 +Like \fB\&.. include:: file\fP directive, \fB\&.. mdinclude:: file\fP directive inserts
233 +markdown file at the line.
234 +.sp
235 +Note: do not use \fB\&.. include:: file\fP directive to include markdown file even if
236 +in the markdown file, please use \fB\&.. mdinclude:: file\fP instead.
237 +.SH RESTRICTIONS
238 +.INDENT 0.0
239 +.IP \(bu 2
240 +In the reST\(aqs directives, markdown is not available. Please write in reST.
241 +.IP \(bu 2
242 +Column alignment of tables is not supported. (reST does not support this feature)
243 +.IP \(bu 2
244 +Heading with overline\-and\-underline is not supported.
245 +.INDENT 2.0
246 +.IP \(bu 2
247 +Heading with underline is OK
248 +.UNINDENT
249 +.UNINDENT
250 +.sp
251 +If you find any bug or unexpected behaviour, please report it to
252 +\fI\%Issues\fP\&.
253 +.SH EXAMPLE
254 +.sp
255 +See \fI\%example document\fP and \fI\%its
256 +source code\fP\&.
257 +.sp
258 +I\(aqm using m2r for writing user guide of \fI\%WDOM\fP\&.
259 +So you can see it as another example. Its \fI\%HTML is
260 +here\fP, and \fI\%its
261 +source code is here\fP\&.
262 +.SH ACKNOWLEDGEMENT
263 +.sp
264 +m2r is written as an extension of
265 +\fI\%mistune\fP, which is highly extensible
266 +pure\-python markdown parser.
267 +Without the mistune, I couldn\(aqt write this. Thank you!
268 +.SH LICENCE
269 +.sp
270 +\fI\%MIT\fP
271 +.SH CONTENTS
272 +.SS Example
273 +.sp
274 +This page is written in mixed markdown and reST.
275 +Source code is \fI\%here\fP\&.
276 +.SS Basic Markups (inline)
277 +.sp
278 +A \fBstrong\fP, \fIemphasis\fP, , \fBcode with single\-backtick\fP,
279 +\fBcode with two\-backticks\fP, ,
280 +\fBreST\(aqs code role\fP, and delete.
281 +.SS Link
282 +.sp
283 +Auto link to \fI\%http://example.com/\fP\&.
284 +.sp
285 +Link to \fI\%example.com\fP in markdown.
286 +.sp
287 +Link to \fI\%example.com\fP in reST.
288 +.sp
289 +Link to \fI\%example\fP in reST_ref.
290 +.SS Basic Markups (block)
291 +.sp
292 +This is a simple sentence.
293 +.nf
294 +sentence with
295 +newlines
296 +(reST)
297 +.fi
298 +.sp
299 +.sp
300 +Sentence with
301 +hard\-wrap (markdown, trailing two spaces)
302 +.INDENT 0.0
303 +.INDENT 3.5
304 +block quote
305 +second line
306 +.INDENT 0.0
307 +.INDENT 3.5
308 +nested quote
309 +.UNINDENT
310 +.UNINDENT
311 +.UNINDENT
312 +.UNINDENT
313 +
314 +.sp
315 +.ce
316 +----
317 +
318 +.ce 0
319 +.sp
320 +.INDENT 0.0
321 +.INDENT 3.5
322 +Block quote after raw\-html directive
323 +.UNINDENT
324 +.UNINDENT
325 +.SS List
326 +.SS Unordered list
327 +.INDENT 0.0
328 +.IP \(bu 2
329 +unordered list
330 +new line
331 +.IP \(bu 2
332 +next item
333 +.INDENT 2.0
334 +.IP \(bu 2
335 +nested list
336 +with new line
337 +.IP \(bu 2
338 +nested list item 2
339 +.UNINDENT
340 +.IP \(bu 2
341 +original depth
342 +.INDENT 2.0
343 +.IP 1. 3
344 +ordered list item
345 +.IP 2. 3
346 +second
347 +with new line
348 +.UNINDENT
349 +.IP \(bu 2
350 +original depth again
351 +.UNINDENT
352 +.SS Ordered list
353 +.INDENT 0.0
354 +.IP 1. 3
355 +ordered list
356 +in new line
357 +.IP 2. 3
358 +second item
359 +.INDENT 3.0
360 +.IP \(bu 2
361 +nested unordered list
362 +.IP \(bu 2
363 +second item
364 +with new line
365 +.UNINDENT
366 +.IP 3. 3
367 +original depth
368 +.INDENT 3.0
369 +.IP 1. 3
370 +nested ordered list
371 +with new line
372 +.IP 2. 3
373 +again
374 +.UNINDENT
375 +.IP 4. 3
376 +original depth again
377 +.UNINDENT
378 +.SS Code Block
379 +.sp
380 +Simple, indented code block
381 +.INDENT 0.0
382 +.INDENT 3.5
383 +.sp
384 +.nf
385 +.ft C
386 +pip install sphinx
387 +.ft P
388 +.fi
389 +.UNINDENT
390 +.UNINDENT
391 +.sp
392 +Code block with triple backticks and language.
393 +.INDENT 0.0
394 +.INDENT 3.5
395 +.sp
396 +.nf
397 +.ft C
398 +def a(n: int) \-> None:
399 + for i in range(n):
400 + print(i)
401 +.ft P
402 +.fi
403 +.UNINDENT
404 +.UNINDENT
405 +.sp
406 +Triple\-tildes (\fB~~~\fP) are also available.
407 +.INDENT 0.0
408 +.INDENT 3.5
409 +.sp
410 +.nf
411 +.ft C
412 +def a(n: int) \-> None:
413 + for i in range(n):
414 + print(i)
415 +.ft P
416 +.fi
417 +.UNINDENT
418 +.UNINDENT
419 +.sp
420 +Here is reST style code block.
421 +.INDENT 0.0
422 +.INDENT 3.5
423 +.sp
424 +.nf
425 +.ft C
426 +if True:
427 + print(\(aq\en\(aq)
428 +.ft P
429 +.fi
430 +.UNINDENT
431 +.UNINDENT
432 +.SS Extensions
433 +.SS Table (Markdown\-Style)
434 +.sp
435 +(cell\-alignment is not supported currently)
436 +.TS
437 +center;
438 +|l|l|l|.
439 +_
440 +T{
441 +Table Header 1
442 +T} T{
443 +Table Header 2
444 +T} T{
445 +Table Header 3
446 +T}
447 +_
448 +T{
449 +normal
450 +T} T{
451 +\fIitalic\fP
452 +T} T{
453 +\fBbold\fP
454 +T}
455 +_
456 +T{
457 +\fBcode\fP
458 +T} T{
459 +T} T{
460 +T}
461 +_
462 +.TE
463 +.SS Math
464 +.sp
465 +This is E = mc^2 inline math.
466 +.sp
467 +The below is math\-block (markdown\-style).
468 +.sp
469 +.ce
470 +
471 +.ce 0
472 +.sp
473 +The below is reST\-style math\-block.
474 +.sp
475 +.ce
476 +
477 +.ce 0
478 +.SS Footnote
479 +.sp
480 +Footnote[2] and footnote[3] with markdown.
481 +.sp
482 +Footnote with reST[1]\&.
483 +.sp
484 +
485 +.IP [1] 5
486 +reST footnote
487 +.IP [2] 5
488 +footnote 1
489 +.IP [3] 5
490 +footnote key
491 +.SS Change Log
492 +.SS Version 0.2
493 +.sp
494 +(next version)
495 +.SS Version 0.1.5 (2016\-06\-21)
496 +.INDENT 0.0
497 +.IP \(bu 2
498 +Support multiple backticks in inline code, like:
499 +.UNINDENT
500 +.SS Version 0.1.4 (2016\-06\-08)
501 +.INDENT 0.0
502 +.IP \(bu 2
503 +Support indented directives/reST\-comments
504 +.IP \(bu 2
505 +Support role\-name after backticks (\fB\(gatext\(ga:role: style\fP)
506 +.UNINDENT
507 +.SS Version 0.1.3 (2016\-06\-02)
508 +.INDENT 0.0
509 +.IP \(bu 2
510 +Remove extra escaped\-spaces (\(aq\(aq)
511 +.INDENT 2.0
512 +.IP \(bu 2
513 +before and after normal spaces
514 +.IP \(bu 2
515 +at the beginning of lines
516 +.IP \(bu 2
517 +before dots
518 +.UNINDENT
519 +.UNINDENT
520 +.SS Version 0.1.2 (2016\-06\-01)
521 +.INDENT 0.0
522 +.IP \(bu 2
523 +Add reST\(aqs \fB::\fP marker support
524 +.IP \(bu 2
525 +Add options to disable emphasis by underscore (\fB_\fP or \fB__\fP)
526 +.UNINDENT
527 +.SS Version 0.1.1 (2016\-05\-30)
528 +.INDENT 0.0
529 +.IP \(bu 2
530 +Fix Bug: when code or link is placed at the end of line, spaces to the next word is disappeared
531 +.UNINDENT
532 +.SS Version 0.1 (2016\-05\-30)
533 +.sp
534 +First public release.
535 +.INDENT 0.0
536 +.IP \(bu 2
537 +genindex
538 +.IP \(bu 2
539 +modindex
540 +.IP \(bu 2
541 +search
542 +.UNINDENT
543 +.SH AUTHOR
544 +Hiroyuki Takagi
545 +.SH COPYRIGHT
546 +2016, Hiroyuki Takagi
547 +.\" Generated by docutils manpage writer.
548 +.
549
550 diff --git a/dev-python/m2r/files/test.md b/dev-python/m2r/files/test.md
551 new file mode 100644
552 index 00000000000..e54ac950e52
553 --- /dev/null
554 +++ b/dev-python/m2r/files/test.md
555 @@ -0,0 +1,5 @@
556 +# Title
557 +
558 +## SubTitle
559 +
560 +__content__
561
562 diff --git a/dev-python/m2r/files/test.rst b/dev-python/m2r/files/test.rst
563 new file mode 100644
564 index 00000000000..f4555887956
565 --- /dev/null
566 +++ b/dev-python/m2r/files/test.rst
567 @@ -0,0 +1,8 @@
568 +
569 +Title
570 +=====
571 +
572 +SubTitle
573 +--------
574 +
575 +**content**
576
577 diff --git a/dev-python/m2r/m2r-0.1.5.ebuild b/dev-python/m2r/m2r-0.1.5.ebuild
578 new file mode 100644
579 index 00000000000..04da2c37410
580 --- /dev/null
581 +++ b/dev-python/m2r/m2r-0.1.5.ebuild
582 @@ -0,0 +1,50 @@
583 +# Copyright 1999-2017 Gentoo Foundation
584 +# Distributed under the terms of the GNU General Public License v2
585 +
586 +EAPI=6
587 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} pypy)
588 +
589 +inherit distutils-r1
590 +
591 +DESCRIPTION="Markdown to reStructuredText converter"
592 +HOMEPAGE="https://github.com/miyakogi/m2r https://pypi.python.org/pypi/m2r"
593 +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
594 +
595 +LICENSE="MIT"
596 +SLOT="0"
597 +KEYWORDS="~amd64 ~x86"
598 +IUSE="test"
599 +
600 +RDEPEND="
601 + dev-python/mistune[${PYTHON_USEDEP}]
602 + dev-python/docutils[${PYTHON_USEDEP}]
603 +"
604 +DEPEND="
605 + dev-python/setuptools[${PYTHON_USEDEP}]
606 + test? ( $(python_gen_cond_dep 'dev-python/mock[${PYTHON_USEDEP}]' python2_7) )
607 + ${RDEPEND}
608 +"
609 +
610 +#S=${WORKDIR}/${P}
611 +
612 +python_prepare_all() {
613 + # fix a Q/A violation, trying to install the tests as an independant package
614 + sed -e "s/packages=\['tests'\],/packages=[],/" -i setup.py
615 + # remove duped old file in the tarball
616 + rm "tests/test_r s.py" || die
617 + # add missing test files
618 + cp "${FILESDIR}/"test.md tests/ || die
619 + cp "${FILESDIR}/"test.rst tests/ || die
620 + cp "${FILESDIR}/"m2r.1 ./ || die
621 +matt
622 + distutils-r1_python_prepare_all
623 +}
624 +
625 +python_test() {
626 + py.test -v || die "Tests failed with ${EPYTHON}"
627 +}
628 +
629 +python_install_all() {
630 + distutils-r1_python_install_all
631 + doman m2r.1
632 +}
633
634 diff --git a/dev-python/m2r/metadata.xml b/dev-python/m2r/metadata.xml
635 new file mode 100644
636 index 00000000000..c560383e607
637 --- /dev/null
638 +++ b/dev-python/m2r/metadata.xml
639 @@ -0,0 +1,19 @@
640 +<?xml version="1.0" encoding="UTF-8"?>
641 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
642 +<pkgmetadata>
643 + <maintainer type="person">
644 + <email>dolsen@g.o</email>
645 + <description>Primary maintainer</description>
646 + </maintainer>
647 + <upstream>
648 + <maintainer>
649 + <email>miyako.dev@×××××.com</email>
650 + <name>Hiroyuki Takagi</name>
651 + </maintainer>
652 + <remote-id type="pypi">m2r</remote-id>
653 + <remote-id type="github">miyakogi/m2r</remote-id>
654 + </upstream>
655 + <longdescription>
656 + M2R converts a markdown file including reST markups to a valid reST format.
657 + </longdescription>
658 +</pkgmetadata>