From 860d17b6876822ef7023fdce70c725d3f8be37b1 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 5 Mar 2021 14:34:46 -0500 Subject: Doc tooling improvements (#1734) * #include an absolute path didn't work - because paths were taken to always be relative. * Split out AST 'printing'. * Replace listener with List
* Section -> Part. * Kind -> Type Flags -> Kind for ASTPrinter::Part * Improve comments around ASTPrinter. * toString -> toText on Val derived types. toText appends to a StringBuilder. * Added toSlice free function. Added operator<< for Val derived types. Use << where appropriate in doing toText. * More work at mark down output. * Fill in sourceloc for enum case. Add more sophisticated location determination for EnumCase. Refactored documentation output into DocMarkdownWriter. * Improvements for sig output. * Split up slang-doc into extractor and writer. * WIP generic support for doc support. * Some refactoring to make DocExtractor have potential to be used without Decls. * Made doc extraction work without Decls. * Output generic parameters. * Add generic parameter extraction. * Added writing variables. * Add an interface test. * Fix toArray. * Support for extensions, and inheritance. * Disable the doc test. Co-authored-by: Tim Foley --- tests/doc/doc.slang | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'tests') diff --git a/tests/doc/doc.slang b/tests/doc/doc.slang index a2298ec4c..b983011c5 100644 --- a/tests/doc/doc.slang +++ b/tests/doc/doc.slang @@ -10,6 +10,41 @@ /// RWStructuredBuffer inputBuffer; + +/// An interface to do things +interface IDoThing +{ + /// Add two integers + int add(int a, ///< First parameter + int b ///< Second parameter + ); + + /// Subtract + /// Multi-line + int sub(int a, ///< First + int b ///< Second + ); +} + +interface IThing +{ + float getValue(); +}; + +/// Implement IThing on float +extension float : IThing +{ + /// Just return the float itself! + float getValue() { return this; } +} + +struct Thing : IThing, IDoThing +{ + int add(int a, int b) { return a + b; } + int sub(int a, int b ) { return a - b; } + float getValue() { return 1.0f; } +}; + /// A struct with some fields struct SomeStruct { @@ -19,6 +54,9 @@ struct SomeStruct /// is a thing int anotherField; int yetAnother; ///< A field with stuff + + /// Get a value + int getMethod() { return yetAnother; } }; /// An enum @@ -48,6 +86,20 @@ int doThing(int a, ///< a parameter return a; } +/// A rather silly generic function to test out doc extraction +T addInts ///< And another one + ( + /// CHECKING!! + T z, ///< The Z parameter + T b) ///< The B parameter +{ + return z + b; +} + [numthreads(4, 1, 1)] void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { -- cgit v1.2.3