[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-03-06 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7003f64c1eb2: [clang-doc] Improving Markdown Output 
(authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D72954?vs=248338=248875#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/single-file.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -47,14 +47,12 @@
 
 ## Namespaces
 
-ChildNamespace
-
+* [ChildNamespace](../ChildNamespace/index.md)
 
 
 ## Records
 
-ChildStruct
-
+* [ChildStruct](../ChildStruct.md)
 
 
 ## Functions
@@ -106,7 +104,7 @@
   assert(!Err);
   std::string Expected = R"raw(# class r
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 Inherits from F, G
 
@@ -171,7 +169,7 @@
 
 *void f(int P)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -202,7 +200,7 @@
 | X |
 
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -331,7 +329,7 @@
 
 *void f(int I, int J)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 
 
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -63,24 +63,24 @@
   std::string Expected = R"raw(
 
 namespace Namespace
-
-
-
+
+
+
 test-project
 
-  
+  
   
 namespace Namespace
 Namespaces
 
   
-ChildNamespace
+ChildNamespace
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
@@ -196,14 +196,14 @@
 
   
 private 
-int
+int
  X
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
Index: clang-tools-extra/test/clang-doc/single-file.cpp
===
--- clang-tools-extra/test/clang-doc/single-file.cpp
+++ clang-tools-extra/test/clang-doc/single-file.cpp
@@ -3,7 +3,7 @@
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp -output=%t/docs
-// RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
+// RUN: cat %t/docs/GlobalNamespace/index.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
 void function(int x);
@@ -12,20 +12,20 @@
 
 // CHECK: ---
 // CHECK-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-NEXT: ChildFunctions:  
+// CHECK-NEXT: ChildFunctions:
 // CHECK-NEXT:   - USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
 // CHECK-NEXT:Name:'function'
-// CHECK-NEXT:DefLocation: 
+// CHECK-NEXT:DefLocation:
 // CHECK-NEXT:  LineNumber:  [[@LINE-8]]
 // CHECK-NEXT:  Filename:'{{.*}}
-// CHECK-NEXT:Location:
+// CHECK-NEXT:Location:
 // CHECK-NEXT:  - LineNumber:  [[@LINE-13]]
 // CHECK-NEXT:Filename:'{{.*}}'
-// CHECK-NEXT:Params:  
-// CHECK-NEXT:  - Type:
+// CHECK-NEXT:Params:
+// CHECK-NEXT:  - Type:
 // CHECK-NEXT:  Name:'int'
 // CHECK-NEXT:Name:'x'
-// CHECK-NEXT:ReturnType:  
-// CHECK-NEXT:  Type:
+// CHECK-NEXT:ReturnType:
+// CHECK-NEXT:  Type:
 // CHECK-NEXT:Name:'void'
 // CHECK-NEXT:...
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- 

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-03-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This is still failing on Windows:

   TEST 'Extra Tools Unit Tests :: 
clang-doc/./ClangDocTests.exe/MDGeneratorTest.emitNamespaceMD' FAILED 

  Note: Google Test filter = MDGeneratorTest.emitNamespaceMD
  
  [==] Running 1 test from 1 test case.
  
  [--] Global test environment set-up.
  
  [--] 1 test from MDGeneratorTest
  
  [ RUN  ] MDGeneratorTest.emitNamespaceMD
  
  
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang-tools-extra\unittests\clang-doc\MDGeneratorTest.cpp(77):
 error:   Expected: Expected
  
Which is: "# namespace Namespace\n\n\n\n## Namespaces\n\n* 
[ChildNamespace](../ChildNamespace/index.md)\n\n\n## Records\n\n* 
[ChildStruct](../ChildStruct.md)\n\n\n## Functions\n\n### OneFunction\n\n* 
OneFunction()*\n\n\n\n## Enums\n\n| enum OneEnum |\n\n--\n\n\n\n\n\n"
  
  To be equal to: Actual.str()
  
Which is: "# namespace Namespace\n\n\n\n## Namespaces\n\n* 
[ChildNamespace](../ChildNamespace/index.md)\n\n\n## Records\n\n* 
[ChildStruct](..//ChildStruct.md)\n\n\n## Functions\n\n### OneFunction\n\n* 
OneFunction()*\n\n\n\n## Enums\n\n| enum OneEnum |\n\n--\n\n\n\n\n\n"
  
  With diff:
  
  @@ -10,5 +10,5 @@
  
   ## Records
  
   
  
  -* [ChildStruct](../ChildStruct.md)
  
  +* [ChildStruct](..//ChildStruct.md)
  
   
  
   
  
  
  
  [  FAILED  ] MDGeneratorTest.emitNamespaceMD (1 ms)
  
  [--] 1 test from MDGeneratorTest (1 ms total)
  
  
  
  [--] Global test environment tear-down
  
  [==] 1 test from 1 test case ran. (1 ms total)
  
  [  PASSED  ] 0 tests.
  
  [  FAILED  ] 1 test, listed below:
  
  [  FAILED  ] MDGeneratorTest.emitNamespaceMD
  
  
  
   1 FAILED TEST


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-03-04 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45499f3801d8: [clang-doc] Improving Markdown Output 
(authored by phosek).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/single-file.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -47,14 +47,12 @@
 
 ## Namespaces
 
-ChildNamespace
-
+* [ChildNamespace](../ChildNamespace/index.md)
 
 
 ## Records
 
-ChildStruct
-
+* [ChildStruct](../ChildStruct.md)
 
 
 ## Functions
@@ -106,7 +104,7 @@
   assert(!Err);
   std::string Expected = R"raw(# class r
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 Inherits from F, G
 
@@ -171,7 +169,7 @@
 
 *void f(int P)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -202,7 +200,7 @@
 | X |
 
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -331,7 +329,7 @@
 
 *void f(int I, int J)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 
 
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -63,24 +63,24 @@
   std::string Expected = R"raw(
 
 namespace Namespace
-
-
-
+
+
+
 test-project
 
-  
+  
   
 namespace Namespace
 Namespaces
 
   
-ChildNamespace
+ChildNamespace
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
@@ -196,14 +196,14 @@
 
   
 private 
-int
+int
  X
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
Index: clang-tools-extra/test/clang-doc/single-file.cpp
===
--- clang-tools-extra/test/clang-doc/single-file.cpp
+++ clang-tools-extra/test/clang-doc/single-file.cpp
@@ -3,7 +3,7 @@
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp -output=%t/docs
-// RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
+// RUN: cat %t/docs/GlobalNamespace/index.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
 void function(int x);
@@ -12,20 +12,20 @@
 
 // CHECK: ---
 // CHECK-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-NEXT: ChildFunctions:  
+// CHECK-NEXT: ChildFunctions:
 // CHECK-NEXT:   - USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
 // CHECK-NEXT:Name:'function'
-// CHECK-NEXT:DefLocation: 
+// CHECK-NEXT:DefLocation:
 // CHECK-NEXT:  LineNumber:  [[@LINE-8]]
 // CHECK-NEXT:  Filename:'{{.*}}
-// CHECK-NEXT:Location:
+// CHECK-NEXT:Location:
 // CHECK-NEXT:  - LineNumber:  [[@LINE-13]]
 // CHECK-NEXT:Filename:'{{.*}}'
-// CHECK-NEXT:Params:  
-// CHECK-NEXT:  - Type:
+// CHECK-NEXT:Params:
+// CHECK-NEXT:  - Type:
 // CHECK-NEXT:  Name:'int'
 // CHECK-NEXT:Name:'x'
-// CHECK-NEXT:ReturnType:  
-// CHECK-NEXT:  Type:
+// CHECK-NEXT:ReturnType:
+// CHECK-NEXT:  Type:
 // CHECK-NEXT:Name:'void'
 // CHECK-NEXT:...
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ 

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-02-12 Thread Clayton Wilkinson via Phabricator via cfe-commits
Clayton updated this revision to Diff 244204.
Clayton added a comment.

Making paths in markdown files be posix style. This fixes the tests on windows 
hosts.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/single-file.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -47,14 +47,12 @@
 
 ## Namespaces
 
-ChildNamespace
-
+* [ChildNamespace](../ChildNamespace/index.md)
 
 
 ## Records
 
-ChildStruct
-
+* [ChildStruct](../ChildStruct.md)
 
 
 ## Functions
@@ -106,7 +104,7 @@
   assert(!Err);
   std::string Expected = R"raw(# class r
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 Inherits from F, G
 
@@ -171,7 +169,7 @@
 
 *void f(int P)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -202,7 +200,7 @@
 | X |
 
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -331,7 +329,7 @@
 
 *void f(int I, int J)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 
 
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -63,24 +63,24 @@
   std::string Expected = R"raw(
 
 namespace Namespace
-
-
-
+
+
+
 test-project
 
-  
+  
   
 namespace Namespace
 Namespaces
 
   
-ChildNamespace
+ChildNamespace
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
@@ -196,14 +196,14 @@
 
   
 private 
-int
+int
  X
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
Index: clang-tools-extra/test/clang-doc/single-file.cpp
===
--- clang-tools-extra/test/clang-doc/single-file.cpp
+++ clang-tools-extra/test/clang-doc/single-file.cpp
@@ -3,7 +3,7 @@
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp -output=%t/docs
-// RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
+// RUN: cat %t/docs/GlobalNamespace/index.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
 void function(int x);
@@ -12,20 +12,20 @@
 
 // CHECK: ---
 // CHECK-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-NEXT: ChildFunctions:  
+// CHECK-NEXT: ChildFunctions:
 // CHECK-NEXT:   - USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
 // CHECK-NEXT:Name:'function'
-// CHECK-NEXT:DefLocation: 
+// CHECK-NEXT:DefLocation:
 // CHECK-NEXT:  LineNumber:  [[@LINE-8]]
 // CHECK-NEXT:  Filename:'{{.*}}
-// CHECK-NEXT:Location:
+// CHECK-NEXT:Location:
 // CHECK-NEXT:  - LineNumber:  [[@LINE-13]]
 // CHECK-NEXT:Filename:'{{.*}}'
-// CHECK-NEXT:Params:  
-// CHECK-NEXT:  - Type:
+// CHECK-NEXT:Params:
+// CHECK-NEXT:  - Type:
 // CHECK-NEXT:  Name:'int'
 // CHECK-NEXT:Name:'x'
-// CHECK-NEXT:ReturnType:  
-// CHECK-NEXT:  Type:
+// CHECK-NEXT:ReturnType:
+// CHECK-NEXT:  Type:
 // CHECK-NEXT:Name:'void'
 // CHECK-NEXT:...
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -294,8 +294,9 @@
   }
 
   doc::Info *I = 

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-02-12 Thread Clayton Wilkinson via Phabricator via cfe-commits
Clayton reopened this revision.
Clayton added a comment.
This revision is now accepted and ready to land.

Re-opening to  fix windows tests failures.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-02-07 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This is failing on Windows:

  ../../clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp(77): error:   
Expected: Expected
Which is: "# namespace Namespace\n\n\n\n## Namespaces\n\n* 
[ChildNamespace](../ChildNamespace/index.md)\n\n\n## Records\n\n* 
[ChildStruct](../ChildStruct.md)\n\n\n## Functions\n\n### OneFunction\n\n* 
OneFunction()*\n\n\n\n## Enums\n\n| enum OneEnum |\n\n--\n\n\n\n\n\n"
  To be equal to: Actual.str()
Which is: "# namespace Namespace\n\n\n\n## Namespaces\n\n* 
[ChildNamespace](..\\ChildNamespace\\index.md)\n\n\n## Records\n\n* 
[ChildStruct](..\\ChildStruct.md)\n\n\n## Functions\n\n### OneFunction\n\n* 
OneFunction()*\n\n\n\n## Enums\n\n| enum OneEnum |\n\n--\n\n\n\n\n\n"
  With diff:
  @@ -5,5 +5,5 @@
   ## Namespaces
   
  -* [ChildNamespace](../ChildNamespace/index.md)
  +* [ChildNamespace](..\\ChildNamespace\\index.md)
   
   
  @@ -10,5 +10,5 @@
   ## Records
   
  -* [ChildStruct](../ChildStruct.md)
  +* [ChildStruct](..\\ChildStruct.md)
   
   
  
  [  FAILED  ] MDGeneratorTest.emitNamespaceMD (1 ms)
  [--] 1 test from MDGeneratorTest (1 ms total)
  
  [--] Global test environment tear-down
  [==] 1 test from 1 test case ran. (1 ms total)
  [  PASSED  ] 0 tests.
  [  FAILED  ] 1 test, listed below:
  [  FAILED  ] MDGeneratorTest.emitNamespaceMD
  
   1 FAILED TEST


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-02-07 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdac21fdd5923: [clang-doc] Improving Markdown Output 
(authored by phosek).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/single-file.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -47,14 +47,12 @@
 
 ## Namespaces
 
-ChildNamespace
-
+* [ChildNamespace](../ChildNamespace/index.md)
 
 
 ## Records
 
-ChildStruct
-
+* [ChildStruct](../ChildStruct.md)
 
 
 ## Functions
@@ -106,7 +104,7 @@
   assert(!Err);
   std::string Expected = R"raw(# class r
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 Inherits from F, G
 
@@ -171,7 +169,7 @@
 
 *void f(int P)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -202,7 +200,7 @@
 | X |
 
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -331,7 +329,7 @@
 
 *void f(int I, int J)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 
 
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -63,24 +63,24 @@
   std::string Expected = R"raw(
 
 namespace Namespace
-
-
-
+
+
+
 test-project
 
-  
+  
   
 namespace Namespace
 Namespaces
 
   
-ChildNamespace
+ChildNamespace
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
@@ -196,14 +196,14 @@
 
   
 private 
-int
+int
  X
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
Index: clang-tools-extra/test/clang-doc/single-file.cpp
===
--- clang-tools-extra/test/clang-doc/single-file.cpp
+++ clang-tools-extra/test/clang-doc/single-file.cpp
@@ -3,7 +3,7 @@
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp -output=%t/docs
-// RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
+// RUN: cat %t/docs/GlobalNamespace/index.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
 void function(int x);
@@ -12,20 +12,20 @@
 
 // CHECK: ---
 // CHECK-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-NEXT: ChildFunctions:  
+// CHECK-NEXT: ChildFunctions:
 // CHECK-NEXT:   - USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
 // CHECK-NEXT:Name:'function'
-// CHECK-NEXT:DefLocation: 
+// CHECK-NEXT:DefLocation:
 // CHECK-NEXT:  LineNumber:  [[@LINE-8]]
 // CHECK-NEXT:  Filename:'{{.*}}
-// CHECK-NEXT:Location:
+// CHECK-NEXT:Location:
 // CHECK-NEXT:  - LineNumber:  [[@LINE-13]]
 // CHECK-NEXT:Filename:'{{.*}}'
-// CHECK-NEXT:Params:  
-// CHECK-NEXT:  - Type:
+// CHECK-NEXT:Params:
+// CHECK-NEXT:  - Type:
 // CHECK-NEXT:  Name:'int'
 // CHECK-NEXT:Name:'x'
-// CHECK-NEXT:ReturnType:  
-// CHECK-NEXT:  Type:
+// CHECK-NEXT:ReturnType:
+// CHECK-NEXT:  Type:
 // CHECK-NEXT:Name:'void'
 // CHECK-NEXT:...
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ 

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-02-06 Thread Clayton Wilkinson via Phabricator via cfe-commits
Clayton updated this revision to Diff 243027.
Clayton added a comment.

Updating tests affected by this change.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/single-file.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -47,14 +47,12 @@
 
 ## Namespaces
 
-ChildNamespace
-
+* [ChildNamespace](../ChildNamespace/index.md)
 
 
 ## Records
 
-ChildStruct
-
+* [ChildStruct](../ChildStruct.md)
 
 
 ## Functions
@@ -106,7 +104,7 @@
   assert(!Err);
   std::string Expected = R"raw(# class r
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 Inherits from F, G
 
@@ -171,7 +169,7 @@
 
 *void f(int P)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -202,7 +200,7 @@
 | X |
 
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -331,7 +329,7 @@
 
 *void f(int I, int J)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 
 
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -63,24 +63,24 @@
   std::string Expected = R"raw(
 
 namespace Namespace
-
-
-
+
+
+
 test-project
 
-  
+  
   
 namespace Namespace
 Namespaces
 
   
-ChildNamespace
+ChildNamespace
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
@@ -196,14 +196,14 @@
 
   
 private 
-int
+int
  X
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
Index: clang-tools-extra/test/clang-doc/single-file.cpp
===
--- clang-tools-extra/test/clang-doc/single-file.cpp
+++ clang-tools-extra/test/clang-doc/single-file.cpp
@@ -3,7 +3,7 @@
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp -output=%t/docs
-// RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
+// RUN: cat %t/docs/GlobalNamespace/index.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
 void function(int x);
@@ -12,20 +12,20 @@
 
 // CHECK: ---
 // CHECK-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-NEXT: ChildFunctions:  
+// CHECK-NEXT: ChildFunctions:
 // CHECK-NEXT:   - USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
 // CHECK-NEXT:Name:'function'
-// CHECK-NEXT:DefLocation: 
+// CHECK-NEXT:DefLocation:
 // CHECK-NEXT:  LineNumber:  [[@LINE-8]]
 // CHECK-NEXT:  Filename:'{{.*}}
-// CHECK-NEXT:Location:
+// CHECK-NEXT:Location:
 // CHECK-NEXT:  - LineNumber:  [[@LINE-13]]
 // CHECK-NEXT:Filename:'{{.*}}'
-// CHECK-NEXT:Params:  
-// CHECK-NEXT:  - Type:
+// CHECK-NEXT:Params:
+// CHECK-NEXT:  - Type:
 // CHECK-NEXT:  Name:'int'
 // CHECK-NEXT:Name:'x'
-// CHECK-NEXT:ReturnType:  
-// CHECK-NEXT:  Type:
+// CHECK-NEXT:ReturnType:
+// CHECK-NEXT:  Type:
 // CHECK-NEXT:Name:'void'
 // CHECK-NEXT:...
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -294,8 +294,9 @@
   }
 
   doc::Info *I = Reduced.get().get();
-  auto InfoPath = 

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-02-06 Thread Clayton Wilkinson via Phabricator via cfe-commits
Clayton reopened this revision.
Clayton added a comment.
This revision is now accepted and ready to land.

Fixing unit tests affected by this change.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-02-03 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0fbaf3a7c239: [clang-doc] Improving Markdown Output 
(authored by phosek).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -294,8 +294,9 @@
   }
 
   doc::Info *I = Reduced.get().get();
-  auto InfoPath = getInfoOutputFile(OutDirectory, I->Path, I->extractName(),
-"." + Format);
+  auto InfoPath =
+  getInfoOutputFile(OutDirectory, I->getRelativeFilePath(""),
+I->getFileBaseName(), "." + Format);
   if (!InfoPath) {
 llvm::errs() << toString(InfoPath.takeError()) << "\n";
 Error = true;
@@ -304,9 +305,9 @@
   std::error_code FileErr;
   llvm::raw_fd_ostream InfoOS(InfoPath.get(), FileErr,
   llvm::sys::fs::OF_None);
-  if (FileErr != OK) {
-llvm::errs() << "Error opening info file: " << FileErr.message()
- << "\n";
+  if (FileErr) {
+llvm::errs() << "Error opening info file " << InfoPath.get() << ": "
+ << FileErr.message() << "\n";
 return;
   }
 
Index: clang-tools-extra/clang-doc/assets/index.js
===
--- clang-tools-extra/clang-doc/assets/index.js
+++ clang-tools-extra/clang-doc/assets/index.js
@@ -31,7 +31,11 @@
 
 function genLink(Ref, CurrentDirectory) {
   var Path = computeRelativePath(Ref.Path, CurrentDirectory);
-  Path = append(Path, Ref.Name + ".html")
+  if (Ref.RefType == "namespace")
+Path = append(Path, "index.html");
+  else
+Path = append(Path, Ref.Name + ".html")
+
   ANode = document.createElement("a");
   ANode.setAttribute("href", Path);
   var TextNode = document.createTextNode(Ref.Name);
Index: clang-tools-extra/clang-doc/Representation.h
===
--- clang-tools-extra/clang-doc/Representation.h
+++ clang-tools-extra/clang-doc/Representation.h
@@ -135,6 +135,12 @@
   bool mergeable(const Reference );
   void merge(Reference &);
 
+  /// Returns the path for this Reference relative to CurrentPath.
+  llvm::SmallString<64> getRelativeFilePath(const StringRef ) const;
+
+  /// Returns the basename that should be used for this Reference.
+  llvm::SmallString<16> getFileBaseName() const;
+
   SymbolID USR = SymbolID(); // Unique identifier for referenced decl
   SmallString<16> Name;  // Name of type (possibly unresolved).
   InfoType RefType = InfoType::IT_default; // Indicates the type of this
@@ -262,6 +268,12 @@
 
   llvm::SmallString<16> extractName() const;
 
+  /// Returns the file path for this Info relative to CurrentPath.
+  llvm::SmallString<64> getRelativeFilePath(const StringRef ) const;
+
+  /// Returns the basename that should be used for this Info.
+  llvm::SmallString<16> getFileBaseName() const;
+
   // Returns a reference to the parent scope (that is, the immediate parent
   // namespace or class in which this decl resides).
   llvm::Expected getEnclosingScope();
Index: clang-tools-extra/clang-doc/Representation.cpp
===
--- clang-tools-extra/clang-doc/Representation.cpp
+++ clang-tools-extra/clang-doc/Representation.cpp
@@ -114,6 +114,52 @@
   }
 }
 
+static llvm::SmallString<64>
+calculateRelativeFilePath(const InfoType , const StringRef ,
+  const StringRef , const StringRef ) {
+  llvm::SmallString<64> FilePath;
+
+  if (CurrentPath != Path) {
+// iterate back to the top
+for (llvm::sys::path::const_iterator I =
+ llvm::sys::path::begin(CurrentPath);
+ I != llvm::sys::path::end(CurrentPath); ++I)
+  llvm::sys::path::append(FilePath, "..");
+llvm::sys::path::append(FilePath, Path);
+  }
+
+  // Namespace references have a Path to the parent namespace, but
+  // the file is actually in the subdirectory for the namespace.
+  if (Type == doc::InfoType::IT_namespace)
+llvm::sys::path::append(FilePath, Name);
+
+  return llvm::sys::path::relative_path(FilePath);
+}
+
+llvm::SmallString<64>
+Reference::getRelativeFilePath(const StringRef ) const {
+  return calculateRelativeFilePath(RefType, Path, Name, CurrentPath);
+}
+
+llvm::SmallString<16> Reference::getFileBaseName() const {
+  if 

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-02-03 Thread Clayton Wilkinson via Phabricator via cfe-commits
Clayton updated this revision to Diff 242066.
Clayton added a comment.

build error fixed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -294,8 +294,9 @@
   }
 
   doc::Info *I = Reduced.get().get();
-  auto InfoPath = getInfoOutputFile(OutDirectory, I->Path, I->extractName(),
-"." + Format);
+  auto InfoPath =
+  getInfoOutputFile(OutDirectory, I->getRelativeFilePath(""),
+I->getFileBaseName(), "." + Format);
   if (!InfoPath) {
 llvm::errs() << toString(InfoPath.takeError()) << "\n";
 Error = true;
@@ -304,9 +305,9 @@
   std::error_code FileErr;
   llvm::raw_fd_ostream InfoOS(InfoPath.get(), FileErr,
   llvm::sys::fs::OF_None);
-  if (FileErr != OK) {
-llvm::errs() << "Error opening info file: " << FileErr.message()
- << "\n";
+  if (FileErr) {
+llvm::errs() << "Error opening info file " << InfoPath.get() << ": "
+ << FileErr.message() << "\n";
 return;
   }
 
Index: clang-tools-extra/clang-doc/assets/index.js
===
--- clang-tools-extra/clang-doc/assets/index.js
+++ clang-tools-extra/clang-doc/assets/index.js
@@ -31,7 +31,11 @@
 
 function genLink(Ref, CurrentDirectory) {
   var Path = computeRelativePath(Ref.Path, CurrentDirectory);
-  Path = append(Path, Ref.Name + ".html")
+  if (Ref.RefType == "namespace")
+Path = append(Path, "index.html");
+  else
+Path = append(Path, Ref.Name + ".html")
+
   ANode = document.createElement("a");
   ANode.setAttribute("href", Path);
   var TextNode = document.createTextNode(Ref.Name);
Index: clang-tools-extra/clang-doc/Representation.h
===
--- clang-tools-extra/clang-doc/Representation.h
+++ clang-tools-extra/clang-doc/Representation.h
@@ -135,6 +135,12 @@
   bool mergeable(const Reference );
   void merge(Reference &);
 
+  /// Returns the path for this Reference relative to CurrentPath.
+  llvm::SmallString<64> getRelativeFilePath(const StringRef ) const;
+
+  /// Returns the basename that should be used for this Reference.
+  llvm::SmallString<16> getFileBaseName() const;
+
   SymbolID USR = SymbolID(); // Unique identifier for referenced decl
   SmallString<16> Name;  // Name of type (possibly unresolved).
   InfoType RefType = InfoType::IT_default; // Indicates the type of this
@@ -262,6 +268,12 @@
 
   llvm::SmallString<16> extractName() const;
 
+  /// Returns the file path for this Info relative to CurrentPath.
+  llvm::SmallString<64> getRelativeFilePath(const StringRef ) const;
+
+  /// Returns the basename that should be used for this Info.
+  llvm::SmallString<16> getFileBaseName() const;
+
   // Returns a reference to the parent scope (that is, the immediate parent
   // namespace or class in which this decl resides).
   llvm::Expected getEnclosingScope();
Index: clang-tools-extra/clang-doc/Representation.cpp
===
--- clang-tools-extra/clang-doc/Representation.cpp
+++ clang-tools-extra/clang-doc/Representation.cpp
@@ -114,6 +114,52 @@
   }
 }
 
+static llvm::SmallString<64>
+calculateRelativeFilePath(const InfoType , const StringRef ,
+  const StringRef , const StringRef ) {
+  llvm::SmallString<64> FilePath;
+
+  if (CurrentPath != Path) {
+// iterate back to the top
+for (llvm::sys::path::const_iterator I =
+ llvm::sys::path::begin(CurrentPath);
+ I != llvm::sys::path::end(CurrentPath); ++I)
+  llvm::sys::path::append(FilePath, "..");
+llvm::sys::path::append(FilePath, Path);
+  }
+
+  // Namespace references have a Path to the parent namespace, but
+  // the file is actually in the subdirectory for the namespace.
+  if (Type == doc::InfoType::IT_namespace)
+llvm::sys::path::append(FilePath, Name);
+
+  return llvm::sys::path::relative_path(FilePath);
+}
+
+llvm::SmallString<64>
+Reference::getRelativeFilePath(const StringRef ) const {
+  return calculateRelativeFilePath(RefType, Path, Name, CurrentPath);
+}
+
+llvm::SmallString<16> Reference::getFileBaseName() const {
+  if (RefType == InfoType::IT_namespace)
+return llvm::SmallString<16>("index");
+
+  return Name;
+}
+

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-02-03 Thread Clayton Wilkinson via Phabricator via cfe-commits
Clayton reopened this revision.
Clayton added a comment.
This revision is now accepted and ready to land.

Fixing build error


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-01-31 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdeae8ee69167: [clang-doc] Improving Markdown Output 
(authored by phosek).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72954/new/

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -294,8 +294,9 @@
   }
 
   doc::Info *I = Reduced.get().get();
-  auto InfoPath = getInfoOutputFile(OutDirectory, I->Path, I->extractName(),
-"." + Format);
+  auto InfoPath =
+  getInfoOutputFile(OutDirectory, I->getRelativeFilePath(""),
+I->getFileBaseName(), "." + Format);
   if (!InfoPath) {
 llvm::errs() << toString(InfoPath.takeError()) << "\n";
 Error = true;
@@ -304,9 +305,9 @@
   std::error_code FileErr;
   llvm::raw_fd_ostream InfoOS(InfoPath.get(), FileErr,
   llvm::sys::fs::OF_None);
-  if (FileErr != OK) {
-llvm::errs() << "Error opening info file: " << FileErr.message()
- << "\n";
+  if (FileErr) {
+llvm::errs() << "Error opening info file " << InfoPath.get() << ": "
+ << FileErr.message() << "\n";
 return;
   }
 
Index: clang-tools-extra/clang-doc/assets/index.js
===
--- clang-tools-extra/clang-doc/assets/index.js
+++ clang-tools-extra/clang-doc/assets/index.js
@@ -31,7 +31,11 @@
 
 function genLink(Ref, CurrentDirectory) {
   var Path = computeRelativePath(Ref.Path, CurrentDirectory);
-  Path = append(Path, Ref.Name + ".html")
+  if (Ref.RefType == "namespace")
+Path = append(Path, "index.html");
+  else
+Path = append(Path, Ref.Name + ".html")
+
   ANode = document.createElement("a");
   ANode.setAttribute("href", Path);
   var TextNode = document.createTextNode(Ref.Name);
Index: clang-tools-extra/clang-doc/Representation.h
===
--- clang-tools-extra/clang-doc/Representation.h
+++ clang-tools-extra/clang-doc/Representation.h
@@ -135,6 +135,12 @@
   bool mergeable(const Reference );
   void merge(Reference &);
 
+  /// Returns the path for this Reference relative to CurrentPath.
+  llvm::SmallString<64> getRelativeFilePath(const StringRef ) const;
+
+  /// Returns the basename that should be used for this Reference.
+  llvm::SmallString<16> getFileBaseName() const;
+
   SymbolID USR = SymbolID(); // Unique identifier for referenced decl
   SmallString<16> Name;  // Name of type (possibly unresolved).
   InfoType RefType = InfoType::IT_default; // Indicates the type of this
@@ -262,6 +268,12 @@
 
   llvm::SmallString<16> extractName() const;
 
+  /// Returns the file path for this Info relative to CurrentPath.
+  llvm::SmallString<64> getRelativeFilePath(const StringRef ) const;
+
+  /// Returns the basename that should be used for this Info.
+  llvm::SmallString<16> getFileBaseName() const;
+
   // Returns a reference to the parent scope (that is, the immediate parent
   // namespace or class in which this decl resides).
   llvm::Expected getEnclosingScope();
Index: clang-tools-extra/clang-doc/Representation.cpp
===
--- clang-tools-extra/clang-doc/Representation.cpp
+++ clang-tools-extra/clang-doc/Representation.cpp
@@ -114,6 +114,52 @@
   }
 }
 
+static llvm::SmallString<64>
+calculateRelativeFilePath(const InfoType , const StringRef ,
+  const StringRef , const StringRef ) {
+  llvm::SmallString<64> FilePath;
+
+  if (CurrentPath != Path) {
+// iterate back to the top
+for (llvm::sys::path::const_iterator I =
+ llvm::sys::path::begin(CurrentPath);
+ I != llvm::sys::path::end(CurrentPath); ++I)
+  llvm::sys::path::append(FilePath, "..");
+llvm::sys::path::append(FilePath, Path);
+  }
+
+  // Namespace references have a Path to the parent namespace, but
+  // the file is actually in the subdirectory for the namespace.
+  if (Type == doc::InfoType::IT_namespace)
+llvm::sys::path::append(FilePath, Name);
+
+  return llvm::sys::path::relative_path(FilePath);
+}
+
+llvm::SmallString<64>
+Reference::getRelativeFilePath(const StringRef ) const {
+  return calculateRelativeFilePath(RefType, Path, Name, CurrentPath);
+}