microsoft/qdk
Publicmirrored from https://github.com/microsoft/qdkAvailable
compiler/qsc_doc_gen/src/generate_docs/tests.rs
54lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | #![allow(clippy::needless_raw_string_hashes)] |
| 5 | |
| 6 | use super::generate_docs; |
| 7 | use expect_test::expect; |
| 8 | |
| 9 | #[test] |
| 10 | fn docs_generation() { |
| 11 | let files = generate_docs(None, None, None); |
| 12 | let (_, metadata, contents) = files |
| 13 | .iter() |
| 14 | .find(|(file_name, _, _)| &**file_name == "Std.Core/Length.md") |
| 15 | .expect("Could not file doc file for Length"); |
| 16 | let full_contents = format!("{metadata}\n\n{contents}"); |
| 17 | |
| 18 | expect![[r#" |
| 19 | --- |
| 20 | uid: Qdk.Std.Core.Length |
| 21 | title: Length function |
| 22 | ms.date: {TIMESTAMP} |
| 23 | ms.topic: managed-reference |
| 24 | qsharp.kind: function |
| 25 | qsharp.namespace: Std.Core |
| 26 | qsharp.name: Length |
| 27 | qsharp.summary: "Returns the number of elements in the input array `a`." |
| 28 | --- |
| 29 | |
| 30 | # Length function |
| 31 | |
| 32 | Fully qualified name: Std.Core.Length |
| 33 | |
| 34 | ```qsharp |
| 35 | function Length<'T>(a : 'T[]) : Int |
| 36 | ``` |
| 37 | |
| 38 | ## Summary |
| 39 | Returns the number of elements in the input array `a`. |
| 40 | |
| 41 | ## Input |
| 42 | ### a |
| 43 | Input array. |
| 44 | |
| 45 | ## Output |
| 46 | The total number of elements in the input array `a`. |
| 47 | |
| 48 | ## Example |
| 49 | ```qsharp |
| 50 | Message($"{ Length([0, 0, 0]) }"); // Prints 3 |
| 51 | ``` |
| 52 | "#]] |
| 53 | .assert_eq(full_contents.as_str()); |
| 54 | } |