Skip to content

Commit

Permalink
WIP-fix living doc
Browse files Browse the repository at this point in the history
TODO: rename paas-template/hello-world/...private-dns.tf
  • Loading branch information
o-orand committed Jun 20, 2018
1 parent 751d9b6 commit 60e1eb4
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 66 deletions.
14 changes: 7 additions & 7 deletions docs/reference_dataset/another-world-root-depls.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ another-world-root-depls

### The root config files

* [another-world-root-depls](/docs/reference_dataset/config_repository/another-world-root-depls)
* [hello-world-root-depls](/docs/reference_dataset/config_repository/hello-world-root-depls)
* [private-config.yml](/docs/reference_dataset/config_repository/private-config.yml)
* [shared](/docs/reference_dataset/config_repository/shared)
* [another-world-root-depls](/docs/reference_dataset/config_repository/another-world-root-depls)
* [hello-world-root-depls](/docs/reference_dataset/config_repository/hello-world-root-depls)
* [private-config.yml](/docs/reference_dataset/config_repository/private-config.yml)
* [shared](/docs/reference_dataset/config_repository/shared)

### The another-world-root-depls files

Expand All @@ -76,9 +76,9 @@ another-world-root-depls

### The root template files

* [another-world-root-depls](/docs/reference_dataset/template_repository/another-world-root-depls)
* [hello-world-root-depls](/docs/reference_dataset/template_repository/hello-world-root-depls)
* [shared-config.yml](/docs/reference_dataset/template_repository/shared-config.yml)
* [another-world-root-depls](/docs/reference_dataset/template_repository/another-world-root-depls)
* [hello-world-root-depls](/docs/reference_dataset/template_repository/hello-world-root-depls)
* [shared-config.yml](/docs/reference_dataset/template_repository/shared-config.yml)

### The another-world-root-depls files

Expand Down
16 changes: 9 additions & 7 deletions docs/reference_dataset/hello-world-root-depls.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ hello-world-root-depls

### The root config files

* [another-world-root-depls](/docs/reference_dataset/config_repository/another-world-root-depls)
* [hello-world-root-depls](/docs/reference_dataset/config_repository/hello-world-root-depls)
* [private-config.yml](/docs/reference_dataset/config_repository/private-config.yml)
* [shared](/docs/reference_dataset/config_repository/shared)
* [another-world-root-depls](/docs/reference_dataset/config_repository/another-world-root-depls)
* [hello-world-root-depls](/docs/reference_dataset/config_repository/hello-world-root-depls)
* [private-config.yml](/docs/reference_dataset/config_repository/private-config.yml)
* [shared](/docs/reference_dataset/config_repository/shared)

### The hello-world-root-depls files

Expand Down Expand Up @@ -160,9 +160,9 @@ hello-world-root-depls

### The root template files

* [another-world-root-depls](/docs/reference_dataset/template_repository/another-world-root-depls)
* [hello-world-root-depls](/docs/reference_dataset/template_repository/hello-world-root-depls)
* [shared-config.yml](/docs/reference_dataset/template_repository/shared-config.yml)
* [another-world-root-depls](/docs/reference_dataset/template_repository/another-world-root-depls)
* [hello-world-root-depls](/docs/reference_dataset/template_repository/hello-world-root-depls)
* [shared-config.yml](/docs/reference_dataset/template_repository/shared-config.yml)

### The hello-world-root-depls files

Expand Down Expand Up @@ -356,6 +356,7 @@ hello-world-root-depls
* cf-ops-automation-branch
* cf-ops-automation-tag-filter
* cf-ops-automation-uri
* iaas-type
* paas-templates-branch
* paas-templates-uri
* secrets-branch
Expand Down Expand Up @@ -458,6 +459,7 @@ hello-world-root-depls

* hello-world-root-depls-concourse-generated.yml
* hello-world-root-depls-generated.yml
* hello-world-root-depls-tf-generated.yml

### nginx-version

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ module FileListWriterHelpers
def pretty_filepath(path, repo_name)
stripped_path = path.strip
filename = File.basename(stripped_path)
return "" if filename[0] == "."
return "" if filename.empty? || filename[0] == "."
prefix = extract_prefix(stripped_path)
cleaned_path = clean_path(stripped_path)
"#{prefix}* [#{filename}](/docs/reference_dataset/#{repo_name}/#{cleaned_path})"
end

def extract_prefix(path)
path_items = path.strip.split('/')
path_items = path.strip.gsub(%r{^.\/}, "").split('/')
" " * (path_items.size - 1)
end

Expand Down
81 changes: 53 additions & 28 deletions spec/lib/reference_dataset_documentation/file_list_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

describe ReferenceDatasetDocumentation::FileListWriter do
let(:find_answer) { File.read(File.join(File.dirname(__FILE__), 'fixtures/find_answer.txt')) }
let(:root_deployment_name) { "root_deployment_name" }
let(:find_root_level_answer) { File.read(File.join(File.dirname(__FILE__), 'fixtures/find_root_level_only_answer.txt')) }
let(:root_deployment_name) { "hello-world-root-depls" }
let(:config_repository) { "config_repo_name" }
let(:template_repository) { "template_repo_name" }
let(:path) { "/path/to/living_docs" }
Expand All @@ -20,35 +21,59 @@
let(:files_writer) { described_class.new(generator) }

it "write a file list source with Unix's `find`" do
expect(files_writer).to receive(:`).with("find #{root_deployment_name.to_s}").twice.
allow(Dir).to receive(:chdir).
with(File.join(generator.config_repo_path)).
and_yield
allow(Dir).to receive(:chdir).
with(File.join(generator.template_repo_path)).
and_yield

expect(files_writer).to receive(:`).with("find . -maxdepth 1|sort").twice.
and_return(find_root_level_answer)
expect(files_writer).to receive(:`).with("find #{root_deployment_name}|sort").twice.
and_return(find_answer)
expect(files_writer).to receive(:`).with("find shared|sort").
and_return(find_answer)
expect(Dir).to receive(:chdir).
with(File.join(generator.config_repo_path)).
and_yield
expect(generator).to receive(:add).
with("## The config files", "")
expect(generator).to receive(:add).
with("* [example-file.yml](/docs/reference_dataset/#{config_repository}/#{root_deployment_name}/example-file.yml)")
expect(generator).to receive(:add).
with("* [example-dir](/docs/reference_dataset/#{config_repository}/#{root_deployment_name}/example-dir)")
expect(generator).to receive(:add).
with(" * [example-file.yml](/docs/reference_dataset/#{config_repository}/#{root_deployment_name}/example-dir/example-file.yml)")
expect(generator).to receive(:add).
with("")

expect(Dir).to receive(:chdir).
with(File.join(generator.template_repo_path, root_deployment_name)).
and_yield
expect(generator).to receive(:add).
with("## The template files", "")
expect(generator).to receive(:add).
with("* [example-file.yml](/docs/reference_dataset/#{template_repository}/#{root_deployment_name}/example-file.yml)")
expect(generator).to receive(:add).
with("* [example-dir](/docs/reference_dataset/#{template_repository}/#{root_deployment_name}/example-dir)")
expect(generator).to receive(:add).
with(" * [example-file.yml](/docs/reference_dataset/#{template_repository}/#{root_deployment_name}/example-dir/example-file.yml)")
expect(generator).to receive(:add).
with("")
allow(generator).to receive(:add)
# expect(generator).to receive(:add).
# with("## The config files", "")
# expect(generator).to receive(:add).
# with("### The root config files", "")
# expect(generator).to receive(:add).
# with("* [example-file.yml](/docs/reference_dataset/#{config_repository}/example-file.yml)")
# expect(generator).to receive(:add).
# with("* [example-dir-1](/docs/reference_dataset/#{config_repository}/example-dir-1)")
# expect(generator).to receive(:add).
# with("* [example-dir-2](/docs/reference_dataset/#{config_repository}/example-dir-2)")
# expect(generator).to receive(:add).
# with("* [shared](/docs/reference_dataset/#{config_repository}/shared)")
#
# expect(generator).to receive(:add).
# with("### The example-dir-1 files", "")
#
# expect(generator).to receive(:add).
# with(" * [example-file.yml](/docs/reference_dataset/#{config_repository}/#{root_deployment_name}/example-file.yml)")
# expect(generator).to receive(:add).
# with(" * [subdir-example-file.yml](/docs/reference_dataset/config_repo_name/example-dir-1/subdir/subdir-example-file.yml)")
# expect(generator).to receive(:add).
# with(" * [example-file.yml](/docs/reference_dataset/#{config_repository}/#{root_deployment_name}/example-dir/example-file.yml)")
# expect(generator).to receive(:add).
# with("")
#
# expect(generator).to receive(:add).
# with("### The shared files", "")
#
# expect(generator).to receive(:add).
# with("## The template files", "")
# expect(generator).to receive(:add).
# with("* [example-file.yml](/docs/reference_dataset/#{template_repository}/#{root_deployment_name}/example-file.yml)")
# expect(generator).to receive(:add).
# with("* [example-dir](/docs/reference_dataset/#{template_repository}/#{root_deployment_name}/example-dir)")
# expect(generator).to receive(:add).
# with(" * [example-file.yml](/docs/reference_dataset/#{template_repository}/#{root_deployment_name}/example-dir/example-file.yml)")
# expect(generator).to receive(:add).
# with("")

files_writer.perform
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.
./.hide-me
./example-file.yml
./example-dir
./example-dir/subdir-example-file.yml
./shared
example-dir-1
example-dir-1/.hide-me
example-dir-1/example-file.yml
example-dir-1/subdir/subdir-example-file.yml

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.
./.hide-me
./another-world-root-depls
./hello-world-root-depls
./private-config.yml
./shared

25 changes: 9 additions & 16 deletions spec/lib/reference_dataset_documentation/tree_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,26 @@
let(:tree_writer) { described_class.new(generator) }

it "write a file list source with Unix's `find`" do
expect(tree_writer).to receive(:`).with("tree --noreport -L 1").
and_return(tree_root_level_answer)

expect(Dir).to receive(:chdir).
allow(tree_writer).to receive(:`)
.and_return(tree_root_level_answer, tree_answer, tree_root_level_answer, tree_answer)
allow(Dir).to receive(:chdir).
with(File.join(generator.config_repo_path)).
and_yield
allow(Dir).to receive(:chdir).
with(File.join(generator.template_repo_path)).
and_yield

expect(generator).to receive(:add).
with("## The config repo", "", "### root level overview", "", "```bash", tree_root_level_answer, "```", "")


expect(Dir).to receive(:chdir).
with(File.join(generator.config_repo_path)).
and_yield

expect(tree_writer).to receive(:`).with("tree --noreport #{root_deployment_name}").
and_return(tree_answer)

expect(generator).to receive(:add).
with("", "### root level overview", "", "```bash", tree_root_level_answer, "```", "")
with("### #{root_deployment_name} overview", "", "```bash", tree_answer, "```", "").twice


expect(Dir).to receive(:chdir).
with(File.join(generator.template_repo_path, root_deployment_name)).
and_yield

expect(generator).to receive(:add).
with("## The template repo", "", "```bash", tree_answer, "```", "")
with("## The template repo", "", "### root level overview", "", "```bash", tree_root_level_answer, "```", "")


tree_writer.perform
Expand Down

0 comments on commit 60e1eb4

Please sign in to comment.