mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 21:46:22 +00:00
validate: inspect: Output valid markdown
So it can be used directly in the documentation Also add a special "all" argument to `gst-validate-1.0 --inspect-action-type` so we can generate the documentation for all action types easily.
This commit is contained in:
parent
0a7b23f566
commit
67d4a39602
3 changed files with 75 additions and 58 deletions
|
@ -841,60 +841,52 @@ static void
|
||||||
print_action_parameter (GString * string, GstValidateActionType * type,
|
print_action_parameter (GString * string, GstValidateActionType * type,
|
||||||
GstValidateActionParameter * param)
|
GstValidateActionParameter * param)
|
||||||
{
|
{
|
||||||
gint nw = 0;
|
gchar *desc;
|
||||||
|
g_string_append_printf (string, "\n\n* `%s`:(%s): ", param->name,
|
||||||
gchar *desc, *tmp;
|
param->mandatory ? "mandatory" : "optional");
|
||||||
gchar *param_head = g_strdup_printf (" %s", param->name);
|
|
||||||
gchar *tmp_head = g_strdup_printf ("\n %-30s : %s",
|
|
||||||
param_head, "something");
|
|
||||||
|
|
||||||
|
|
||||||
while (tmp_head[nw] != ':')
|
|
||||||
nw++;
|
|
||||||
|
|
||||||
g_free (tmp_head);
|
|
||||||
|
|
||||||
tmp = g_strdup_printf ("\n%*s", nw + 1, " ");
|
|
||||||
|
|
||||||
if (g_strcmp0 (param->description, "")) {
|
if (g_strcmp0 (param->description, "")) {
|
||||||
desc =
|
desc = g_strdup (param->description);
|
||||||
g_regex_replace (newline_regex, param->description,
|
|
||||||
-1, 0, tmp, 0, NULL);
|
|
||||||
} else {
|
} else {
|
||||||
desc = g_strdup ("No description");
|
desc = g_strdup ("__No description__");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_append_printf (string, "\n %-30s : %s", param_head, desc);
|
g_string_append (string, desc);
|
||||||
g_free (desc);
|
g_free (desc);
|
||||||
|
|
||||||
if (param->possible_variables) {
|
if (param->possible_variables) {
|
||||||
gchar *tmp1 = g_strdup_printf ("\n%*s", nw + 4, " ");
|
|
||||||
desc =
|
desc =
|
||||||
g_regex_replace (newline_regex,
|
g_regex_replace (newline_regex,
|
||||||
param->possible_variables, -1, 0, tmp1, 0, NULL);
|
param->possible_variables, -1, 0, "\n\n * ", 0, NULL);
|
||||||
g_string_append_printf (string, "%sPossible variables:%s%s", tmp,
|
g_string_append_printf (string, "\n\n Possible variables:\n\n * %s",
|
||||||
tmp1, desc);
|
desc);
|
||||||
|
|
||||||
g_free (tmp1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param->types) {
|
if (param->types)
|
||||||
gchar *tmp1 = g_strdup_printf ("\n%*s", nw + 4, " ");
|
g_string_append_printf (string, "\n\n Possible types: `%s`", param->types);
|
||||||
desc = g_regex_replace (newline_regex, param->types, -1, 0, tmp1, 0, NULL);
|
|
||||||
g_string_append_printf (string, "%sPossible types:%s%s", tmp, tmp1, desc);
|
|
||||||
|
|
||||||
g_free (tmp1);
|
if (!param->mandatory)
|
||||||
}
|
g_string_append_printf (string, "\n\n Default: %s", param->def);
|
||||||
|
|
||||||
if (!param->mandatory) {
|
}
|
||||||
g_string_append_printf (string, "%sDefault: %s", tmp, param->def);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_string_append_printf (string, "%s%s", tmp,
|
static void
|
||||||
param->mandatory ? "Mandatory." : "Optional.");
|
print_action_parameter_prototype (GString * string,
|
||||||
|
GstValidateActionParameter * param, gboolean is_first)
|
||||||
|
{
|
||||||
|
if (!is_first)
|
||||||
|
g_string_append (string, ",");
|
||||||
|
g_string_append (string, "\n ");
|
||||||
|
|
||||||
g_free (tmp);
|
if (!param->mandatory)
|
||||||
g_free (param_head);
|
g_string_append (string, "[");
|
||||||
|
|
||||||
|
g_string_append (string, param->name);
|
||||||
|
if (param->types)
|
||||||
|
g_string_append_printf (string, "=(%s)", param->types);
|
||||||
|
|
||||||
|
if (!param->mandatory)
|
||||||
|
g_string_append (string, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -915,8 +907,8 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
|
||||||
|
|
||||||
} else if (*(GType *) source == GST_TYPE_VALIDATE_ACTION_TYPE) {
|
} else if (*(GType *) source == GST_TYPE_VALIDATE_ACTION_TYPE) {
|
||||||
gint i;
|
gint i;
|
||||||
gchar *desc;
|
|
||||||
gboolean has_parameters = FALSE;
|
gboolean has_parameters = FALSE;
|
||||||
|
gboolean is_first = TRUE;
|
||||||
|
|
||||||
GstValidateActionParameter playback_time_param = {
|
GstValidateActionParameter playback_time_param = {
|
||||||
.name = "playback-time",
|
.name = "playback-time",
|
||||||
|
@ -924,8 +916,8 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
|
||||||
.mandatory = FALSE,
|
.mandatory = FALSE,
|
||||||
.types = "double,string",
|
.types = "double,string",
|
||||||
.possible_variables =
|
.possible_variables =
|
||||||
"position: The current position in the stream\n"
|
"`position`: The current position in the stream\n"
|
||||||
"duration: The duration of the stream",
|
"`duration`: The duration of the stream",
|
||||||
.def = "0.0"
|
.def = "0.0"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -944,21 +936,37 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
|
||||||
|
|
||||||
GstValidateActionType *type = GST_VALIDATE_ACTION_TYPE (source);
|
GstValidateActionType *type = GST_VALIDATE_ACTION_TYPE (source);
|
||||||
|
|
||||||
g_string_assign (string, "\nAction type:");
|
g_string_append_printf (string, "\n## %s\n\n", type->name);
|
||||||
|
|
||||||
|
g_string_append_printf (string, "\n``` validate-scenario\n%s,",
|
||||||
|
type->name);
|
||||||
|
|
||||||
|
if (!IS_CONFIG_ACTION_TYPE (type->flags)) {
|
||||||
|
print_action_parameter_prototype (string, &playback_time_param,
|
||||||
|
is_first);
|
||||||
|
is_first = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; type->parameters[i].name; i++) {
|
||||||
|
print_action_parameter_prototype (string, &type->parameters[i],
|
||||||
|
is_first);
|
||||||
|
is_first = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_string_append (string, ";\n```\n");
|
||||||
|
|
||||||
|
g_string_append_printf (string, "\n%s", type->description);
|
||||||
g_string_append_printf (string,
|
g_string_append_printf (string,
|
||||||
"\n Name: %s\n Implementer namespace: %s",
|
"\n * Implementer namespace: %s", type->implementer_namespace);
|
||||||
type->name, type->implementer_namespace);
|
|
||||||
|
|
||||||
if (IS_CONFIG_ACTION_TYPE (type->flags))
|
if (IS_CONFIG_ACTION_TYPE (type->flags))
|
||||||
g_string_append_printf (string,
|
g_string_append_printf (string,
|
||||||
"\n Is config action (meaning it will be executing right "
|
"\n * Is config action (meaning it will be executing right "
|
||||||
"at the beginning of the execution of the pipeline)");
|
"at the beginning of the execution of the pipeline)");
|
||||||
|
|
||||||
|
|
||||||
desc = g_regex_replace (newline_regex, type->description, -1, 0, "\n ",
|
if (type->parameters || !IS_CONFIG_ACTION_TYPE (type->flags))
|
||||||
0, NULL);
|
g_string_append_printf (string, "\n\n### Parameters");
|
||||||
g_string_append_printf (string, "\n\n Description: \n %s", desc);
|
|
||||||
g_free (desc);
|
|
||||||
|
|
||||||
if (!IS_CONFIG_ACTION_TYPE (type->flags)) {
|
if (!IS_CONFIG_ACTION_TYPE (type->flags)) {
|
||||||
g_string_append_printf (string, "\n\n Parameters:");
|
g_string_append_printf (string, "\n\n Parameters:");
|
||||||
|
@ -981,12 +989,12 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
|
||||||
g_string_append_printf (string,
|
g_string_append_printf (string,
|
||||||
"\n optional : "
|
"\n optional : "
|
||||||
"Don't raise an error if this action hasn't been executed or failed"
|
"Don't raise an error if this action hasn't been executed or failed"
|
||||||
"\n%-32s Possible types:"
|
"\n%-32s ### Possible types:"
|
||||||
"\n%-32s boolean" "\n%-32s Default: false", "", "", "");
|
"\n%-32s boolean" "\n%-32s Default: false", "", "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_parameters)
|
if (!has_parameters)
|
||||||
g_string_append_printf (string, "\n\n No Parameters");
|
g_string_append_printf (string, "\n\n ### No Parameters");
|
||||||
} else if (GST_IS_VALIDATE_REPORTER (source) &&
|
} else if (GST_IS_VALIDATE_REPORTER (source) &&
|
||||||
gst_validate_reporter_get_name (source)) {
|
gst_validate_reporter_get_name (source)) {
|
||||||
g_string_printf (string, "\n%s --> ",
|
g_string_printf (string, "\n%s --> ",
|
||||||
|
|
|
@ -4606,10 +4606,15 @@ gst_validate_print_action_types (const gchar ** wanted_types,
|
||||||
{
|
{
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
gint nfound = 0;
|
gint nfound = 0;
|
||||||
|
gboolean print_all = (num_wanted_types == 1
|
||||||
|
&& !g_strcmp0 (wanted_types[0], "all"));
|
||||||
|
|
||||||
|
if (print_all)
|
||||||
|
gst_validate_printf (NULL, "# GstValidate action types");
|
||||||
|
|
||||||
for (tmp = gst_validate_list_action_types (); tmp; tmp = tmp->next) {
|
for (tmp = gst_validate_list_action_types (); tmp; tmp = tmp->next) {
|
||||||
GstValidateActionType *atype = (GstValidateActionType *) tmp->data;
|
GstValidateActionType *atype = (GstValidateActionType *) tmp->data;
|
||||||
gboolean print = FALSE;
|
gboolean print = print_all;
|
||||||
|
|
||||||
if (num_wanted_types) {
|
if (num_wanted_types) {
|
||||||
gint n;
|
gint n;
|
||||||
|
@ -4641,7 +4646,7 @@ gst_validate_print_action_types (const gchar ** wanted_types,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_wanted_types && num_wanted_types > nfound) {
|
if (!print_all && num_wanted_types && num_wanted_types > nfound) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4834,8 +4839,9 @@ init_scenarios (void)
|
||||||
.description = "The starting value of the seek",
|
.description = "The starting value of the seek",
|
||||||
.mandatory = TRUE,
|
.mandatory = TRUE,
|
||||||
.types = "double or string (GstClockTime)",
|
.types = "double or string (GstClockTime)",
|
||||||
.possible_variables = "position: The current position in the stream\n"
|
.possible_variables =
|
||||||
"duration: The duration of the stream",
|
"`position`: The current position in the stream\n"
|
||||||
|
"`duration`: The duration of the stream",
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4876,8 +4882,9 @@ init_scenarios (void)
|
||||||
.description = "The stop value of the seek",
|
.description = "The stop value of the seek",
|
||||||
.mandatory = FALSE,
|
.mandatory = FALSE,
|
||||||
.types = "double or string (GstClockTime)",
|
.types = "double or string (GstClockTime)",
|
||||||
.possible_variables = "position: The current position in the stream\n"
|
.possible_variables =
|
||||||
"duration: The duration of the stream",
|
"`position`: The current position in the stream\n"
|
||||||
|
"`duration`: The duration of the stream",
|
||||||
.def ="GST_CLOCK_TIME_NONE",
|
.def ="GST_CLOCK_TIME_NONE",
|
||||||
},
|
},
|
||||||
{NULL}
|
{NULL}
|
||||||
|
|
|
@ -335,7 +335,9 @@ main (int argc, gchar ** argv)
|
||||||
{"inspect-action-type", 't', 0, G_OPTION_ARG_NONE, &inspect_action_type,
|
{"inspect-action-type", 't', 0, G_OPTION_ARG_NONE, &inspect_action_type,
|
||||||
"Inspect the available action types with which to write scenarios."
|
"Inspect the available action types with which to write scenarios."
|
||||||
" Specify an action type if you want its full description."
|
" Specify an action type if you want its full description."
|
||||||
" If no action type is given the full list of available ones gets printed.",
|
" If no action type is given the full list of available ones gets printed."
|
||||||
|
"Note that passing \"all\" as action type name, makes it output the"
|
||||||
|
" full documentation for all types.",
|
||||||
NULL},
|
NULL},
|
||||||
{"set-media-info", '\0', 0, G_OPTION_ARG_FILENAME, &media_info,
|
{"set-media-info", '\0', 0, G_OPTION_ARG_FILENAME, &media_info,
|
||||||
"Set a media_info XML file descriptor to share information about the"
|
"Set a media_info XML file descriptor to share information about the"
|
||||||
|
|
Loading…
Reference in a new issue