From 151a6f86dde4e469e12f065e9dc4c29d2e885769 Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Fri, 10 Jan 2025 17:51:22 +0100 Subject: [PATCH] fix: Multiple links --- bundle/internal/schema/annotations.go | 2 +- bundle/internal/schema/annotations_test.go | 56 ++++++++++------------ bundle/schema/jsonschema.json | 22 ++++----- 3 files changed, 38 insertions(+), 42 deletions(-) diff --git a/bundle/internal/schema/annotations.go b/bundle/internal/schema/annotations.go index b857fddda..54631835e 100644 --- a/bundle/internal/schema/annotations.go +++ b/bundle/internal/schema/annotations.go @@ -184,7 +184,7 @@ func convertLinksToAbsoluteUrl(s string) string { referencePage := "/dev-tools/bundles/reference.html" // Regular expression to match Markdown-style links like [_](link) - re := regexp.MustCompile(`\[(.*)\]\(([^)]+)\)`) + re := regexp.MustCompile(`\[(.*?)\]\((.*?)\)`) result := re.ReplaceAllStringFunc(s, func(match string) string { matches := re.FindStringSubmatch(match) if len(matches) < 2 { diff --git a/bundle/internal/schema/annotations_test.go b/bundle/internal/schema/annotations_test.go index 782d2d634..0e1593359 100644 --- a/bundle/internal/schema/annotations_test.go +++ b/bundle/internal/schema/annotations_test.go @@ -9,37 +9,33 @@ func TestConvertLinksToAbsoluteUrl(t *testing.T) { input string expected string }{ - // { - // input: "", - // expected: "", - // }, - // { - // input: "Some text (not a link)", - // expected: "Some text (not a link)", - // }, - // { - // input: "This is a link to [_](#section)", - // expected: "This is a link to [section](https://docs.databricks.com/dev-tools/bundles/reference.html#section)", - // }, - // { - // input: "This is a link to [_](/dev-tools/bundles/resources.html#dashboard)", - // expected: "This is a link to [dashboard](https://docs.databricks.com/dev-tools/bundles/resources.html#dashboard)", - // }, - // { - // input: "This is a link to [_](/dev-tools/bundles/resources.html)", - // expected: "This is a link to [link](https://docs.databricks.com/dev-tools/bundles/resources.html)", - // }, - // { - // input: "This is a link to [external](https://external.com)", - // expected: "This is a link to [external](https://external.com)", - // }, - // { - // input: "This is a link to [pipelines](/api/workspace/pipelines/create)", - // expected: "This is a link to [pipelines](https://docs.databricks.com/api/workspace/pipelines/create)", - // }, { - input: "The registered model resource allows you to define models in \u003cUC\u003e. For information about \u003cUC\u003e [registered models](/api/workspace/registeredmodels/create), [registered models 2](/api/workspace/registeredmodels/create)", - expected: "The registered model resource allows you to define models in \u003cUC\u003e. For information about \u003cUC\u003e [registered models](/api/workspace/registeredmodels/create), [registered models 2](/api/workspace/registeredmodels/create)", + input: "", + expected: "", + }, + { + input: "Some text (not a link)", + expected: "Some text (not a link)", + }, + { + input: "This is a link to [_](#section)", + expected: "This is a link to [section](https://docs.databricks.com/dev-tools/bundles/reference.html#section)", + }, + { + input: "This is a link to [_](/dev-tools/bundles/resources.html#dashboard)", + expected: "This is a link to [dashboard](https://docs.databricks.com/dev-tools/bundles/resources.html#dashboard)", + }, + { + input: "This is a link to [_](/dev-tools/bundles/resources.html)", + expected: "This is a link to [link](https://docs.databricks.com/dev-tools/bundles/resources.html)", + }, + { + input: "This is a link to [external](https://external.com)", + expected: "This is a link to [external](https://external.com)", + }, + { + input: "This is a link to [one](/relative), [two](/relative-2)", + expected: "This is a link to [one](https://docs.databricks.com/relative), [two](https://docs.databricks.com/relative-2)", }, } diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index 4cc8d0d46..990a2f133 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -248,7 +248,7 @@ } }, "additionalProperties": false, - "markdownDescription": "The dashboard resource allows you to manage [AI/BI dashboards](/api/workspace/lakeview/create) in a bundle. For information about AI/BI dashboards, see [_](https://docs.databricks.com/dashboards/index.html)." + "markdownDescription": "The dashboard resource allows you to manage [AI/BI dashboards](https://docs.databricks.com/api/workspace/lakeview/create) in a bundle. For information about AI/BI dashboards, see [link](https://docs.databricks.com/dashboards/index.html)." }, { "type": "string", @@ -370,7 +370,7 @@ } }, "additionalProperties": false, - "markdownDescription": "The job resource allows you to define [jobs and their corresponding tasks](/api/workspace/jobs/create) in your bundle. For information about jobs, see [_](/jobs/index.md). For a tutorial that uses a \u003cDABS\u003e template to create a job, see [_](https://docs.databricks.com/dev-tools/bundles/jobs-tutorial.html)." + "markdownDescription": "The job resource allows you to define [jobs and their corresponding tasks](https://docs.databricks.com/api/workspace/jobs/create) in your bundle. For information about jobs, see [link](https://docs.databricks.com/jobs/index.html). For a tutorial that uses a \u003cDABS\u003e template to create a job, see [link](https://docs.databricks.com/dev-tools/bundles/jobs-tutorial.html)." }, { "type": "string", @@ -416,7 +416,7 @@ } }, "additionalProperties": false, - "markdownDescription": "The experiment resource allows you to define [MLflow experiments](/api/workspace/experiments/createexperiment) in a bundle. For information about MLflow experiments, see [_](https://docs.databricks.com/mlflow/experiments.html)." + "markdownDescription": "The experiment resource allows you to define [MLflow experiments](https://docs.databricks.com/api/workspace/experiments/createexperiment) in a bundle. For information about MLflow experiments, see [link](https://docs.databricks.com/mlflow/experiments.html)." }, { "type": "string", @@ -507,7 +507,7 @@ "config", "name" ], - "markdownDescription": "The model_serving_endpoint resource allows you to define [model serving endpoints](/api/workspace/servingendpoints/create). See [_](https://docs.databricks.com/machine-learning/model-serving/manage-serving-endpoints.html)." + "markdownDescription": "The model_serving_endpoint resource allows you to define [model serving endpoints](https://docs.databricks.com/api/workspace/servingendpoints/create). See [link](https://docs.databricks.com/machine-learning/model-serving/manage-serving-endpoints.html)." }, { "type": "string", @@ -650,7 +650,7 @@ } }, "additionalProperties": false, - "markdownDescription": "The pipeline resource allows you to create \u003cDLT\u003e [pipelines](/api/workspace/pipelines/create). For information about pipelines, see [_](/delta-live-tables/index.md). For a tutorial that uses the \u003cDABS\u003e template to create a pipeline, see [_](https://docs.databricks.com/dev-tools/bundles/pipelines-tutorial.html)." + "markdownDescription": "The pipeline resource allows you to create \u003cDLT\u003e [pipelines](https://docs.databricks.com/api/workspace/pipelines/create). For information about pipelines, see [link](https://docs.databricks.com/delta-live-tables/index.html). For a tutorial that uses the \u003cDABS\u003e template to create a pipeline, see [link](https://docs.databricks.com/dev-tools/bundles/pipelines-tutorial.html)." }, { "type": "string", @@ -725,7 +725,7 @@ "assets_dir", "output_schema_name" ], - "markdownDescription": "The quality_monitor resource allows you to define a \u003cUC\u003e [table monitor](/api/workspace/qualitymonitors/create). For information about monitors, see [_](https://docs.databricks.com/machine-learning/model-serving/monitor-diagnose-endpoints.html)." + "markdownDescription": "The quality_monitor resource allows you to define a \u003cUC\u003e [table monitor](https://docs.databricks.com/api/workspace/qualitymonitors/create). For information about monitors, see [link](https://docs.databricks.com/machine-learning/model-serving/monitor-diagnose-endpoints.html)." }, { "type": "string", @@ -768,7 +768,7 @@ "name", "schema_name" ], - "markdownDescription": "The registered model resource allows you to define models in \u003cUC\u003e. For information about \u003cUC\u003e [registered models](/api/workspace/registeredmodels/create), see [_](https://docs.databricks.com/machine-learning/manage-model-lifecycle/index.html)." + "markdownDescription": "The registered model resource allows you to define models in \u003cUC\u003e. For information about \u003cUC\u003e [registered models](https://docs.databricks.com/api/workspace/registeredmodels/create), see [link](https://docs.databricks.com/machine-learning/manage-model-lifecycle/index.html)." }, { "type": "string", @@ -809,7 +809,7 @@ "catalog_name", "name" ], - "markdownDescription": "The schema resource type allows you to define \u003cUC\u003e [schemas](https://docs.databricks.com/api/workspace/schemas/create) for tables and other assets in your workflows and pipelines created as part of a bundle. A schema, different from other resource types, has the following limitations:\n\n- The owner of a schema resource is always the deployment user, and cannot be changed. If `run_as` is specified in the bundle, it will be ignored by operations on the schema.\n- Only fields supported by the corresponding [Schemas object create API](/api/workspace/schemas/create) are available for the schema resource. For example, `enable_predictive_optimization` is not supported as it is only available on the [update API](https://docs.databricks.com/api/workspace/schemas/update)." + "markdownDescription": "The schema resource type allows you to define \u003cUC\u003e [schemas](https://docs.databricks.com/api/workspace/schemas/create) for tables and other assets in your workflows and pipelines created as part of a bundle. A schema, different from other resource types, has the following limitations:\n\n- The owner of a schema resource is always the deployment user, and cannot be changed. If `run_as` is specified in the bundle, it will be ignored by operations on the schema.\n- Only fields supported by the corresponding [Schemas object create API](https://docs.databricks.com/api/workspace/schemas/create) are available for the schema resource. For example, `enable_predictive_optimization` is not supported as it is only available on the [update API](https://docs.databricks.com/api/workspace/schemas/update)." }, { "type": "string", @@ -1048,12 +1048,12 @@ "deployment": { "description": "The definition of the bundle deployment", "$ref": "#/$defs/github.com/databricks/cli/bundle/config.Deployment", - "markdownDescription": "The definition of the bundle deployment. For supported attributes, see [_](#deployment) and [_](https://docs.databricks.com/dev-tools/bundles/deployment-modes.html)." + "markdownDescription": "The definition of the bundle deployment. For supported attributes, see [deployment](https://docs.databricks.com/dev-tools/bundles/reference.html#deployment) and [link](https://docs.databricks.com/dev-tools/bundles/deployment-modes.html)." }, "git": { "description": "The Git version control details that are associated with your bundle.", "$ref": "#/$defs/github.com/databricks/cli/bundle/config.Git", - "markdownDescription": "The Git version control details that are associated with your bundle. For supported attributes, see [_](#git) and [_](https://docs.databricks.com/dev-tools/bundles/settings.html#git)." + "markdownDescription": "The Git version control details that are associated with your bundle. For supported attributes, see [git](https://docs.databricks.com/dev-tools/bundles/reference.html#git) and [git](https://docs.databricks.com/dev-tools/bundles/settings.html#git)." }, "name": { "description": "The name of the bundle.", @@ -6433,7 +6433,7 @@ "permissions": { "description": "Defines a permission for a specific entity.", "$ref": "#/$defs/slice/github.com/databricks/cli/bundle/config/resources.Permission", - "markdownDescription": "A Sequence that defines the permissions to apply to experiments, jobs, pipelines, and models defined in the bundle, where each item in the sequence is a permission for a specific entity.\n\nSee [_](/dev-tools/bundles/settings.md#permissions) and [_](https://docs.databricks.com/dev-tools/bundles/permissions.html)." + "markdownDescription": "A Sequence that defines the permissions to apply to experiments, jobs, pipelines, and models defined in the bundle, where each item in the sequence is a permission for a specific entity.\n\nSee [permissions](https://docs.databricks.com/dev-tools/bundles/settings.html#permissions) and [link](https://docs.databricks.com/dev-tools/bundles/permissions.html)." }, "presets": { "description": "Defines bundle deployment presets.",