[devhelp/drop-devhelp1-format: 90/90] Drop Devhelp 1 index format
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/drop-devhelp1-format: 90/90] Drop Devhelp 1 index format
- Date: Thu, 10 Feb 2022 22:31:36 +0000 (UTC)
commit e53996d811d3da6f6247482fd7874ed7b9d02b42
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri Jul 23 21:54:40 2021 +0100
Drop Devhelp 1 index format
The Devhelp 2 format was introduced 16 years ago; the Devhelp 1 format
was officially deprecated in 2017. It's time to let it go.
The only project that still ships a ".devhelp" file is libxml2:
https://gitlab.gnome.org/GNOME/libxml2/-/issues/295
devhelp/dh-book.c | 4 ++--
devhelp/dh-error.h | 3 ++-
devhelp/dh-parser.c | 28 ++++++++--------------------
devhelp/dh-util-lib.c | 2 --
unit-tests/test-util.c | 10 +---------
5 files changed, 13 insertions(+), 34 deletions(-)
---
diff --git a/devhelp/dh-book.c b/devhelp/dh-book.c
index a58098be..cebcbe1d 100644
--- a/devhelp/dh-book.c
+++ b/devhelp/dh-book.c
@@ -21,8 +21,8 @@
*
* A #DhBook usually contains the documentation for one library (or
* application), for example GLib or GTK. A #DhBook corresponds to one index
- * file. An index file is a file with the extension `*.devhelp`, `*.devhelp2`,
- * `*.devhelp.gz` or `*.devhelp2.gz`.
+ * file. An index file is a file with the extension `*.devhelp2` or
+ * `*.devhelp2.gz`.
*
* #DhBook creates a #GFileMonitor on the index file, and emits the
* #DhBook::updated or #DhBook::deleted signal in case the index file has
diff --git a/devhelp/dh-error.h b/devhelp/dh-error.h
index 8a489fc1..fddeef2f 100644
--- a/devhelp/dh-error.h
+++ b/devhelp/dh-error.h
@@ -15,7 +15,8 @@ G_BEGIN_DECLS
#define DH_ERROR _dh_error_quark ()
typedef enum {
- DH_ERROR_MALFORMED_BOOK
+ DH_ERROR_MALFORMED_BOOK,
+ DH_ERROR_UNSUPPORTED_FORMAT
} DhError;
G_GNUC_INTERNAL
diff --git a/devhelp/dh-parser.c b/devhelp/dh-parser.c
index cb3ae5d9..bc358cff 100644
--- a/devhelp/dh-parser.c
+++ b/devhelp/dh-parser.c
@@ -45,7 +45,7 @@
#define BYTES_PER_READ 4096
typedef enum {
- FORMAT_VERSION_1,
+ FORMAT_VERSION_INVALID,
/* The main change is that version 2 uses <keyword> instead of
* <function>.
@@ -301,15 +301,6 @@ parser_start_node_keyword (DhParser *parser,
"Expected <keyword> element, got <%s> at line %d, column %d.",
node_name, line, col);
return;
- } else if (parser->version == FORMAT_VERSION_1 &&
- g_ascii_strcasecmp (node_name, "function") != 0) {
- g_markup_parse_context_get_position (context, &line, &col);
- g_set_error (error,
- DH_ERROR,
- DH_ERROR_MALFORMED_BOOK,
- "Expected <function> element, got <%s> at line %d, column %d.",
- node_name, line, col);
- return;
}
for (attr_num = 0; attribute_names[attr_num] != NULL; attr_num++) {
@@ -545,14 +536,11 @@ _dh_parser_read_file (GFile *index_file,
if (g_str_has_suffix (index_file_uri, ".devhelp2")) {
parser->version = FORMAT_VERSION_2;
gz = FALSE;
- } else if (g_str_has_suffix (index_file_uri, ".devhelp")) {
- parser->version = FORMAT_VERSION_1;
- gz = FALSE;
} else if (g_str_has_suffix (index_file_uri, ".devhelp2.gz")) {
parser->version = FORMAT_VERSION_2;
gz = TRUE;
} else {
- parser->version = FORMAT_VERSION_1;
+ parser->version = FORMAT_VERSION_INVALID;
gz = TRUE;
}
@@ -573,12 +561,12 @@ _dh_parser_read_file (GFile *index_file,
/* At this point we know that the file exists, the G_IO_ERROR_NOT_FOUND
* has been catched earlier. So print warning.
*/
- if (parser->version == FORMAT_VERSION_1)
- g_warning ("The file '%s' uses the Devhelp index file format version 1, "
- "which is deprecated. A future version of Devhelp may remove "
- "the support for the format version 1. The index file should "
- "be ported to the Devhelp index file format version 2.",
- index_file_uri);
+ if (parser->version == FORMAT_VERSION_INVALID) {
+ g_set_error_literal (error, DH_ERROR, DH_ERROR_UNSUPPORTED_FORMAT,
+ "Unsupported Devhelp index file format");
+ ok = FALSE;
+ goto exit;
+ }
if (gz) {
GZlibDecompressor *zlib_decompressor;
diff --git a/devhelp/dh-util-lib.c b/devhelp/dh-util-lib.c
index 15a5c060..5fd8cc44 100644
--- a/devhelp/dh-util-lib.c
+++ b/devhelp/dh-util-lib.c
@@ -167,8 +167,6 @@ _dh_util_get_possible_index_files (GFile *book_directory)
const gchar *extensions[] = {
".devhelp2",
".devhelp2.gz",
- ".devhelp",
- ".devhelp.gz",
NULL
};
gchar *directory_name;
diff --git a/unit-tests/test-util.c b/unit-tests/test-util.c
index d83f8c4a..6b9e7ce2 100644
--- a/unit-tests/test-util.c
+++ b/unit-tests/test-util.c
@@ -17,7 +17,7 @@ check_get_possible_index_files (const gchar *book_directory_path,
book_directory = g_file_new_for_path (book_directory_path);
list = _dh_util_get_possible_index_files (book_directory);
- g_assert_cmpint (g_slist_length (list), ==, 4);
+ g_assert_cmpint (g_slist_length (list), ==, 2);
for (l = list, i = 0; l != NULL; l = l->next, i++) {
GFile *index_file = G_FILE (l->data);
@@ -35,14 +35,6 @@ check_get_possible_index_files (const gchar *book_directory_path,
expected_basename = g_strconcat (book_basename, ".devhelp2.gz", NULL);
break;
- case 2:
- expected_basename = g_strconcat (book_basename, ".devhelp", NULL);
- break;
-
- case 3:
- expected_basename = g_strconcat (book_basename, ".devhelp.gz", NULL);
- break;
-
default:
g_assert_not_reached ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]