From 04da3ec808593a4fd3a3da3f0acb9efad90d4520 Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Fri, 6 Jan 2017 15:16:33 -0800 Subject: [PATCH 1/9] CI - added tests for relative links Signed-off-by: Adrien Duermael --- tests/src/validator/html_test.go | 58 ++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/tests/src/validator/html_test.go b/tests/src/validator/html_test.go index f5de687ff12..1bd7f7cf85c 100644 --- a/tests/src/validator/html_test.go +++ b/tests/src/validator/html_test.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "golang.org/x/net/html" + "net/url" "os" "path/filepath" "regexp" @@ -48,7 +49,7 @@ func TestURLs(t *testing.T) { count++ - err = testURLs(htmlBytes) + err = testURLs(htmlBytes, path) if err != nil { t.Error(err.Error(), "-", relPath) } @@ -62,7 +63,7 @@ func TestURLs(t *testing.T) { // testURLs tests if we're not using absolute paths for URLs // when pointing to local pages. -func testURLs(htmlBytes []byte) error { +func testURLs(htmlBytes []byte, htmlPath string) error { reader := bytes.NewReader(htmlBytes) @@ -78,7 +79,7 @@ func testURLs(htmlBytes []byte) error { case html.StartTagToken: t := z.Token() - url := "" + urlStr := "" // check tag types switch t.Data { @@ -89,7 +90,7 @@ func testURLs(htmlBytes []byte) error { if !ok { break } - url = href + urlStr = href case "img": countImages++ @@ -97,14 +98,46 @@ func testURLs(htmlBytes []byte) error { if !ok { return errors.New("img with no src: " + t.String()) } - url = src + urlStr = src } // there's an url to test! - if url != "" { - if strings.HasPrefix(url, "http://docs.docker.com") || strings.HasPrefix(url, "https://docs.docker.com") { + if urlStr != "" { + u, err := url.Parse(urlStr) + if err != nil { + return errors.New("can't parse url: " + t.String()) + } + // test with github.com + if u.Scheme != "" && u.Host == "docs.docker.com" { return errors.New("found absolute link: " + t.String()) } + + // relative link + if u.Scheme == "" { + p := filepath.Join(htmlPath, mdToHtmlPath(u.Path)) + if _, err := os.Stat(p); os.IsNotExist(err) { + + fail := true + + // index.html could mean there's a corresponding index.md meaning built the correct path + // but Jekyll actually creates index.html files for all md files. + // foo.md -> foo/index.html + // it does this to prettify urls, content of foo.md would then be rendered here: + // http://domain.com/foo/ (instead of http://domain.com/foo.html) + // so if there's an error, let's see if index.md exists, otherwise retry from parent folder + if filepath.Base(htmlPath) == "index.html" { + // retry from parent folder + p = filepath.Join(filepath.Dir(htmlPath), "..", mdToHtmlPath(u.Path)) + if _, err := os.Stat(p); err == nil { + fail = false + } + } + + if fail { + return errors.New("relative link to non-existent resource: " + t.String()) + } + } + } } } } @@ -112,6 +145,17 @@ func testURLs(htmlBytes []byte) error { return nil } +func mdToHtmlPath(mdPath string) string { + if strings.HasSuffix(mdPath, ".md") == false { + // file is not a markdown, don't change anything + return mdPath + } + if strings.HasSuffix(mdPath, "index.md") { + return strings.TrimSuffix(mdPath, "md") + "html" + } + return strings.TrimSuffix(mdPath, ".md") + "/index.html" +} + // helpers func getHref(t html.Token) (ok bool, href string) { From d6cb69202baa8b9a003bcd2de04af9f7c930e39e Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Mon, 9 Jan 2017 11:22:08 -0800 Subject: [PATCH 2/9] fixes to check relative links properly Signed-off-by: Adrien Duermael --- tests/src/validator/html_test.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/src/validator/html_test.go b/tests/src/validator/html_test.go index 1bd7f7cf85c..1a1f6e7ab68 100644 --- a/tests/src/validator/html_test.go +++ b/tests/src/validator/html_test.go @@ -15,15 +15,16 @@ import ( var countLinks = 0 var countImages = 0 +var htmlContentRootPath = "/usr/src/app/allvbuild" // TestURLs tests if we're not using absolute paths for URLs // when pointing to local pages. func TestURLs(t *testing.T) { count := 0 - filepath.Walk("/usr/src/app/allvbuild", func(path string, info os.FileInfo, err error) error { + filepath.Walk(htmlContentRootPath, func(path string, info os.FileInfo, err error) error { - relPath := strings.TrimPrefix(path, "/usr/src/app/allvbuild") + relPath := strings.TrimPrefix(path, htmlContentRootPath) isArchive, err := regexp.MatchString(`^/v[0-9]+\.[0-9]+/.*`, relPath) if err != nil { @@ -114,8 +115,18 @@ func testURLs(htmlBytes []byte, htmlPath string) error { // relative link if u.Scheme == "" { - p := filepath.Join(htmlPath, mdToHtmlPath(u.Path)) - if _, err := os.Stat(p); os.IsNotExist(err) { + + resourcePath := "" + resourcePathIsAbs := false + + if filepath.IsAbs(u.Path) { + resourcePath = filepath.Join(htmlContentRootPath, mdToHtmlPath(u.Path)) + resourcePathIsAbs = true + } else { + resourcePath = filepath.Join(filepath.Dir(htmlPath), mdToHtmlPath(u.Path)) + } + + if _, err := os.Stat(resourcePath); os.IsNotExist(err) { fail := true @@ -125,10 +136,11 @@ func testURLs(htmlBytes []byte, htmlPath string) error { // it does this to prettify urls, content of foo.md would then be rendered here: // http://domain.com/foo/ (instead of http://domain.com/foo.html) // so if there's an error, let's see if index.md exists, otherwise retry from parent folder - if filepath.Base(htmlPath) == "index.html" { + // (only if the resource path is not absolute) + if !resourcePathIsAbs && filepath.Base(htmlPath) == "index.html" { // retry from parent folder - p = filepath.Join(filepath.Dir(htmlPath), "..", mdToHtmlPath(u.Path)) - if _, err := os.Stat(p); err == nil { + resourcePath = filepath.Join(filepath.Dir(htmlPath), "..", mdToHtmlPath(u.Path)) + if _, err := os.Stat(resourcePath); err == nil { fail = false } } From cbe1b319d58d4ab2c2061aa95228cbf9f41d3925 Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Mon, 9 Jan 2017 11:38:55 -0800 Subject: [PATCH 3/9] /engine/extend/plugins/ -> /engine/extend/legacy_plugins/ Signed-off-by: Adrien Duermael --- _data/toc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/toc.yaml b/_data/toc.yaml index 5aaca34dc1e..bca23bf2261 100644 --- a/_data/toc.yaml +++ b/_data/toc.yaml @@ -271,7 +271,7 @@ toc: title: Managed plugin system - path: /engine/extend/plugins_authorization/ title: Access authorization plugin - - path: /engine/extend/plugins/ + - path: /engine/extend/legacy_plugins/ title: Extending Engine with plugins - path: /engine/extend/plugins_network/ title: Docker network driver plugins From c84767953d4cdfe6da87e53681377b77b8d23b8e Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Mon, 9 Jan 2017 11:55:50 -0800 Subject: [PATCH 4/9] =?UTF-8?q?do=20not=20build=20/tests=20folder=20with?= =?UTF-8?q?=20Jekyll=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Duermael --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 48ca51ff17d..fd12c3cebe0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,7 @@ RUN svn co https://github.com/docker/docker/branches/$ENGINE_BRANCH/docs/referen && svn co https://github.com/docker/distribution/branches/$DISTRIBUTION_BRANCH/docs/spec allv/registry/spec \ && wget -O allv/registry/configuration.md https://raw.githubusercontent.com/docker/distribution/$DISTRIBUTION_BRANCH/docs/configuration.md \ && rm -rf allv/apidocs/cloud-api-source \ + && rm -rf allv/tests \ && jekyll build -s allv -d allvbuild \ && find allvbuild/engine/reference -type f -name '*.html' -print0 | xargs -0 sed -i 's#href="https://docs.docker.com/#href="/#g' \ && find allvbuild/engine/extend -type f -name '*.html' -print0 | xargs -0 sed -i 's#href="https://docs.docker.com/#href="/#g' \ From a81ec77d6e6fcfd819198f5284014769a8dff237 Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Mon, 9 Jan 2017 12:22:52 -0800 Subject: [PATCH 5/9] list all problematic urls in each file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit don’t stop at first error encountered Signed-off-by: Adrien Duermael --- tests/src/validator/html_test.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/src/validator/html_test.go b/tests/src/validator/html_test.go index 1a1f6e7ab68..316c4401ec6 100644 --- a/tests/src/validator/html_test.go +++ b/tests/src/validator/html_test.go @@ -52,7 +52,7 @@ func TestURLs(t *testing.T) { err = testURLs(htmlBytes, path) if err != nil { - t.Error(err.Error(), "-", relPath) + t.Error(relPath + err.Error()) } return nil }) @@ -70,13 +70,17 @@ func testURLs(htmlBytes []byte, htmlPath string) error { z := html.NewTokenizer(reader) - for { + urlErrors := "" + // fmt.Println("urlErrors:", urlErrors) + done := false + + for !done { tt := z.Next() switch tt { case html.ErrorToken: // End of the document, we're done - return nil + done = true case html.StartTagToken: t := z.Token() @@ -97,7 +101,8 @@ func testURLs(htmlBytes []byte, htmlPath string) error { countImages++ ok, src := getSrc(t) if !ok { - return errors.New("img with no src: " + t.String()) + urlErrors += "\nimg with no src: " + t.String() + break } urlStr = src } @@ -106,11 +111,14 @@ func testURLs(htmlBytes []byte, htmlPath string) error { if urlStr != "" { u, err := url.Parse(urlStr) if err != nil { - return errors.New("can't parse url: " + t.String()) + urlErrors += "\ncan't parse url: " + t.String() + break + // return errors.New("can't parse url: " + t.String()) } // test with github.com if u.Scheme != "" && u.Host == "docs.docker.com" { - return errors.New("found absolute link: " + t.String()) + urlErrors += "\nabsolute: " + t.String() + break } // relative link @@ -146,7 +154,8 @@ func testURLs(htmlBytes []byte, htmlPath string) error { } if fail { - return errors.New("relative link to non-existent resource: " + t.String()) + urlErrors += "\nbroken: " + t.String() + break } } } @@ -154,6 +163,10 @@ func testURLs(htmlBytes []byte, htmlPath string) error { } } + // fmt.Println("urlErrors:", urlErrors) + if urlErrors != "" { + return errors.New(urlErrors) + } return nil } From 341562feef9eaebd17b3e2861773a2376692c417 Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Mon, 9 Jan 2017 13:12:28 -0800 Subject: [PATCH 6/9] =?UTF-8?q?removed=20=E2=80=9Cstack=20tasks=E2=80=9D?= =?UTF-8?q?=20from=20menu=20(toc.yaml)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Duermael --- _data/toc.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/_data/toc.yaml b/_data/toc.yaml index bca23bf2261..c28ce210333 100644 --- a/_data/toc.yaml +++ b/_data/toc.yaml @@ -435,8 +435,6 @@ toc: title: stack rm - path: /engine/reference/commandline/stack_services/ title: stack services - - path: /engine/reference/commandline/stack_tasks/ - title: stack tasks - path: /engine/reference/commandline/start/ title: start - path: /engine/reference/commandline/stats/ From 31bd9debd2db537bfd5cf796330320e2c5e64f93 Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Mon, 9 Jan 2017 13:34:46 -0800 Subject: [PATCH 7/9] fixed broken links Signed-off-by: Adrien Duermael --- swarm/install-w-machine.md | 2 +- swarm/networking.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/swarm/install-w-machine.md b/swarm/install-w-machine.md index d1eba122343..c6fcdaeaf16 100644 --- a/swarm/install-w-machine.md +++ b/swarm/install-w-machine.md @@ -239,7 +239,7 @@ your swarm, and start an image on your swarm. $ docker run -it ubuntu bash ``` - For more examples and ideas, visit the [User Guide](/userguide/). + For more examples and ideas, visit the [User Guide](/engine/userguide/intro/). 5. Use the `docker ps` command to find out which node the container ran on. diff --git a/swarm/networking.md b/swarm/networking.md index 1d45ad37d65..a99eb08d3d5 100644 --- a/swarm/networking.md +++ b/swarm/networking.md @@ -12,7 +12,7 @@ container networks that span multiple Docker hosts. Before using Swarm with a custom network, read through the conceptual information in [Docker container -networking](/engine/userguide/networking/dockernetworks/). +networking](/engine/userguide/networking/). You should also have walked through the [Get started with multi-host networking](/engine/userguide/networking/get-started-overlay/) example. From 6e9b529f5b8823bebecbe24c8e55ce6f337014c1 Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Mon, 9 Jan 2017 13:39:02 -0800 Subject: [PATCH 8/9] fixed broken link in docker-for-mac/osxfs.md Signed-off-by: Adrien Duermael --- docker-for-mac/osxfs.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-for-mac/osxfs.md b/docker-for-mac/osxfs.md index cf15e164ce9..7f4e4b0f65a 100644 --- a/docker-for-mac/osxfs.md +++ b/docker-for-mac/osxfs.md @@ -200,9 +200,7 @@ associated issues and on reducing the file system data path latency. This requires significant analysis of file system traces and speculative development of system improvements to try to address specific performance issues. Perhaps surprisingly, application workload can have a huge effect on performance. As an -example, here are two different use cases contributed on the [forum topic]([File -access in mounted volumes extremely -slow](https://forums.docker.com/t/file-access-in-mounted-volumes-extremely-slow-cpu-bound/))) +example, here are two different use cases contributed on the [forum topic](https://forums.docker.com/t/file-access-in-mounted-volumes-extremely-slow-cpu-bound/) and how their performance differs and suffers due to latency, caching, and coherence: From a855031bc389c0b29a8d8c8dec67dfacf74db05a Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Tue, 10 Jan 2017 11:10:13 -0800 Subject: [PATCH 9/9] fixed broken links in /index.html Signed-off-by: Adrien Duermael --- _includes/content/typical_docker_workflow.md | 6 +++--- index.md | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/_includes/content/typical_docker_workflow.md b/_includes/content/typical_docker_workflow.md index e9ea7cc50f1..673adf7387c 100644 --- a/_includes/content/typical_docker_workflow.md +++ b/_includes/content/typical_docker_workflow.md @@ -11,10 +11,10 @@ - Build, then run your containers on a virtual host via [Docker Machine](machine/overview.md) as you develop. 2. Configure [networking](engine/tutorials/networkingcontainers.md) and [storage](engine/tutorials/dockervolumes.md) for your solution, if needed. -3. Upload builds to a registry ([ours](engine/tutorials/dockerrepos.md), [yours](docker-trusted-registry/index.md), or your cloud provider's), to collaborate with your team. +3. Upload builds to a registry ([ours](engine/tutorials/dockerrepos.md), [yours](/datacenter/dtr/2.0/index.md), or your cloud provider's), to collaborate with your team. 4. If you're gonna need to scale your solution across multiple hosts (VMs or physical machines), [plan for how you'll set up your Swarm cluster](engine/swarm/key-concepts.md) and [scale it to meet demand](engine/swarm/swarm-tutorial/index.md). - - Note: Use [Universal Control Plane](ucp/overview.md) and you can manage your + - Note: Use [Universal Control Plane](/datacenter/ucp/1.1/overview.md) and you can manage your Swarm cluster using a friendly UI! 5. Finally, deploy to your preferred - cloud provider (or, for redundancy, *multiple* cloud providers) with [Docker Cloud](docker-cloud/overview.md). Or, use [Docker Datacenter](https://www.docker.com/products/docker-datacenter), and deploy to your own on-premise hardware. + cloud provider (or, for redundancy, *multiple* cloud providers) with [Docker Cloud](/docker-cloud/index.md). Or, use [Docker Datacenter](https://www.docker.com/products/docker-datacenter), and deploy to your own on-premise hardware. diff --git a/index.md b/index.md index b63fde221f8..3d03574e0d8 100644 --- a/index.md +++ b/index.md @@ -66,11 +66,11 @@ title: Docker Documentation
  • - Docker Hub + Docker Hub
    -

    Docker Hub

    +

    Docker Hub

    A hosted registry service for managing and building images.

    @@ -78,11 +78,11 @@ title: Docker Documentation
  • - Docker Cloud + Docker Cloud
    -

    Docker Cloud

    +

    Docker Cloud

    A hosted service for building, testing, and deploying Docker images to your hosts.