Skip to content
Snippets Groups Projects
Commit 27847c18 authored by Jan Alexander Steffens (heftig)'s avatar Jan Alexander Steffens (heftig)
Browse files

1.26+10+g01844e7-1

parent e3ce074a
No related branches found
Tags 24.05.1-1
No related merge requests found
From f4e102a45feb94030002f102f3ef6474401bcd1a Mon Sep 17 00:00:00 2001
Message-Id: <f4e102a45feb94030002f102f3ef6474401bcd1a.1502882026.git.jan.steffens@gmail.com>
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Wed, 16 Aug 2017 13:00:09 +0200
Subject: [PATCH] gtkdoc: Don't immediately choke on non-UTF-8 files
---
gtkdoc/mkdb.py | 13 +++++++++++--
gtkdoc/scan.py | 12 ++++++++++--
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/gtkdoc/mkdb.py b/gtkdoc/mkdb.py
index e103138f3dc6ede4..382195df6348c6a5 100644
--- a/gtkdoc/mkdb.py
+++ b/gtkdoc/mkdb.py
@@ -24,7 +24,7 @@ Creates the DocBook files from the source comments.
"""
from __future__ import print_function
-from six import iteritems, iterkeys
+from six import iteritems, iterkeys, PY2
from collections import OrderedDict
import logging
@@ -3665,18 +3665,27 @@ def ScanSourceFile(ifile, ignore_files):
logging.info("Scanning source file: %s", ifile)
- SRCFILE = open(ifile)
+ SRCFILE = open(ifile, 'rb')
in_comment_block = False
symbol = None
in_part = ''
description = ''
return_desc = ''
since_desc = stability_desc = deprecated_desc = ''
params = OrderedDict()
param_name = None
line_number = 0
for line in SRCFILE:
line_number += 1
+
+ # FIXME Make a better effort at scanning non-UTF-8 files
+ if not PY2:
+ try:
+ line = line.decode()
+ except UnicodeDecodeError:
+ logging.warn('Skipping non-UTF-8 line: %r', line)
+ continue
+
# Look for the start of a comment block.
if not in_comment_block:
if re.search(r'^\s*/\*.*\*/', line):
diff --git a/gtkdoc/scan.py b/gtkdoc/scan.py
index 084351959ba9c700..e8b88e8e88bda7ee 100644
--- a/gtkdoc/scan.py
+++ b/gtkdoc/scan.py
@@ -34,7 +34,7 @@ organized into sections ready to output the XML pages.
"""
from __future__ import print_function
-from six import iteritems, iterkeys
+from six import iteritems, iterkeys, PY2
import logging
import os
@@ -226,7 +226,15 @@ def ScanHeader(input_file, section_list, decl_list, get_types, options):
logging.info('Scanning %s', input_file)
- for line in open(input_file):
+ for line in open(input_file, 'rb'):
+ # FIXME Make a better effort at scanning non-UTF-8 files
+ if not PY2:
+ try:
+ line = line.decode()
+ except UnicodeDecodeError:
+ logging.warn('Skipping non-UTF-8 line: %r', line)
+ continue
+
# If this is a private header, skip it.
if re.search(r'%^\s*/\*\s*<\s*private_header\s*>\s*\*/', line):
return
--
2.14.1
# Maintainer: Jan de Groot <jgc@archlinux.org>
pkgname=gtk-doc
pkgver=1.26
pkgver=1.26+10+g01844e7
pkgrel=1
pkgdesc="Documentation tool for public library API"
url="https://www.gtk.org/gtk-doc/"
......@@ -11,11 +11,11 @@ depends=(docbook-xsl docbook-xml source-highlight glib2-docs python-six)
makedepends=(dblatex git yelp-tools)
checkdepends=(bc gtk3)
optdepends=('dblatex: PDF support')
_commit=4c7bf464748963b275e0bf656beb6c12d48924df # tags/GTK_DOC_1_26^0
_commit=01844e70cae73bfc95a7746fd958c1756a62c340 # master
source=("git+https://git.gnome.org/browse/gtk-doc#commit=$_commit"
gtkdoc.patch)
0001-gtkdoc-Don-t-immediately-choke-on-non-UTF-8-files.patch)
sha256sums=('SKIP'
'0ccf34e1a523b7a9dce3d66eca845847bcd985335c1d61168bdd7cde93b07552')
'ff885d4c6cd4697ebd5855cf57a674dbd1b5a17c2b315e437638ad4a993bd133')
pkgver() {
cd $pkgname
......@@ -24,7 +24,11 @@ pkgver() {
prepare() {
cd $pkgname
patch -Np1 -i ../gtkdoc.patch
patch -Np1 -i ../0001-gtkdoc-Don-t-immediately-choke-on-non-UTF-8-files.patch
# Recover a file from the old version, because GStreamer/common needs it
git checkout 1db161bd708cdfb88b362ea0b5d047034d9c3272 -- gtkdoc-common.pl.in
NOCONFIGURE=1 ./autogen.sh
}
......@@ -42,4 +46,6 @@ check() {
package() {
cd $pkgname
make DESTDIR="$pkgdir" install
sed 's|@PERL@|/usr/bin/perl|g' gtkdoc-common.pl.in \
| install -D /dev/stdin "$pkgdir/usr/share/gtk-doc/data/gtkdoc-common.pl"
}
diff --git i/tests/annotations/docs/tester-docs.xml w/tests/annotations/docs/tester-docs.xml
index e2abf742039ad3c7..7d80f9daef5450b4 100644
--- i/tests/annotations/docs/tester-docs.xml
+++ w/tests/annotations/docs/tester-docs.xml
@@ -16,15 +16,15 @@
</releaseinfo>
</bookinfo>
- <reference label="II">
+ <reference label="2">
<title>API Reference</title>
<chapter id="main-api">
<title>Tests</title>
<xi:include href="xml/tester.xml"/>
</chapter>
</reference>
- <part label="III">
+ <part label="3">
<title>Appendix</title>
<index id="api-index">
diff --git i/tests/common.py w/tests/common.py
index 3f782208f8792f34..8b45f1d404e740ff 100755
--- i/tests/common.py
+++ w/tests/common.py
@@ -20,24 +20,33 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-import mock
+try:
+ from unittest import mock
+except ImportError:
+ import mock
+
+try:
+ import builtins
+except ImportError:
+ import __builtin__ as builtins
+
import unittest
from gtkdoc import common
class TestUpdateFileIfChanged(unittest.TestCase):
@mock.patch('os.path.exists')
@mock.patch('os.rename')
def test_NoOldFile(self, os_rename, os_path_exists):
os_path_exists.return_value = False
res = common.UpdateFileIfChanged('/old', '/new', False)
os_rename.assert_called_with('/new', '/old')
self.assertTrue(res)
@mock.patch('os.path.exists')
- @mock.patch('__builtin__.open', mock.mock_open(read_data='bar'))
+ @mock.patch('builtins.open', mock.mock_open(read_data='bar'))
@mock.patch('os.unlink')
def test_FilesAreTheSame(self, os_unlink, os_path_exists):
os_path_exists.return_value = True
diff --git i/tests/gobject/docs/tester-docs.xml w/tests/gobject/docs/tester-docs.xml
index a534c557b2d04d67..05117ef166ee0b49 100644
--- i/tests/gobject/docs/tester-docs.xml
+++ w/tests/gobject/docs/tester-docs.xml
@@ -37,28 +37,28 @@
</para>
</preface>
- <part label="I" id="part.i">
+ <part label="1" id="part.i">
<title>Overview</title>
<chapter id="Overview-building">
<title>How to build the library</title>
<para></para>
</chapter>
</part>
- <reference label="II" id="part.ii">
+ <reference label="2" id="part.ii">
<title>API Reference</title>
<chapter id="main-api">
<title>Tests</title>
<xi:include href="xml/object.xml"/>
<xi:include href="xml/object2.xml"/>
<xi:include href="xml/object3.xml"/>
<xi:include href="xml/iface.xml"/>
<xi:include href="xml/iface2.xml"/>
<xi:include href="xml/types.xml"/>
</chapter>
</reference>
- <part label="III" id="part.iii">
+ <part label="3" id="part.iii">
<title>Appendix</title>
<chapter id="object-tree">
diff --git i/tests/gtk-doc.make w/tests/gtk-doc.make
index 808fda4f1db02dd3..cb8e164b53e80baf 100644
--- i/tests/gtk-doc.make
+++ w/tests/gtk-doc.make
@@ -141,6 +141,9 @@ sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(HF
sgml.stamp: sgml-build.stamp
@true
+$(DOC_MAIN_SGML_FILE): sgml-build.stamp
+ @true
+
xml/gtkdocentities.ent: Makefile
@$(MKDIR_P) $(@D) && ( \
echo "<!ENTITY package \"$(PACKAGE)\">"; \
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment