Patchwork doc: use modern import style in runrst

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 6, 2018, 1:34 p.m.
Message ID <2fe4d0e1c9baf2e5ac6d.1536240860@mimosa>
Download mbox | patch
Permalink /patch/34370/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 6, 2018, 1:34 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1536239541 -32400
#      Thu Sep 06 22:12:21 2018 +0900
# Node ID 2fe4d0e1c9baf2e5ac6dc601089a2ce0228b42aa
# Parent  7df9ae38c75ca7fd4d0d20802fbc4ab489bb1f06
doc: use modern import style in runrst
Augie Fackler - Sept. 7, 2018, 3:53 p.m.
queued, thanks

> On Sep 6, 2018, at 9:34 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1536239541 -32400
> #      Thu Sep 06 22:12:21 2018 +0900
> # Node ID 2fe4d0e1c9baf2e5ac6dc601089a2ce0228b42aa
> # Parent  7df9ae38c75ca7fd4d0d20802fbc4ab489bb1f06
> doc: use modern import style in runrst
> 
> diff --git a/doc/runrst b/doc/runrst
> --- a/doc/runrst
> +++ b/doc/runrst
> @@ -12,11 +12,14 @@
> where WRITER is the name of a Docutils writer such as 'html' or 'manpage'
> """
> 
> +from __future__ import absolute_import
> +
> import sys
> try:
> -    from docutils.parsers.rst import roles
> -    from docutils.core import publish_cmdline
> -    from docutils import nodes, utils
> +    import docutils.core as core
> +    import docutils.nodes as nodes
> +    import docutils.utils as utils
> +    import docutils.parsers.rst.roles as roles
> except ImportError:
>     sys.stderr.write("abort: couldn't generate documentation: docutils "
>                      "module is missing\n")
> @@ -58,4 +61,4 @@ if __name__ == "__main__":
>     writer = sys.argv[1]
>     del sys.argv[1]
> 
> -    publish_cmdline(writer_name=writer)
> +    core.publish_cmdline(writer_name=writer)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/doc/runrst b/doc/runrst
--- a/doc/runrst
+++ b/doc/runrst
@@ -12,11 +12,14 @@ 
 where WRITER is the name of a Docutils writer such as 'html' or 'manpage'
 """
 
+from __future__ import absolute_import
+
 import sys
 try:
-    from docutils.parsers.rst import roles
-    from docutils.core import publish_cmdline
-    from docutils import nodes, utils
+    import docutils.core as core
+    import docutils.nodes as nodes
+    import docutils.utils as utils
+    import docutils.parsers.rst.roles as roles
 except ImportError:
     sys.stderr.write("abort: couldn't generate documentation: docutils "
                      "module is missing\n")
@@ -58,4 +61,4 @@  if __name__ == "__main__":
     writer = sys.argv[1]
     del sys.argv[1]
 
-    publish_cmdline(writer_name=writer)
+    core.publish_cmdline(writer_name=writer)