| 1 | #Region "Microsoft.VisualBasic::a1f3521e25056208defb95628b4b9281, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\Serialization\NamespaceDoc.vb" |
| 2 | |
| 3 | ' Author: |
| 4 | ' |
| 5 | ' asuka (amethyst.asuka@gcmodeller.org) |
| 6 | ' xie (genetics@smrucc.org) |
| 7 | ' xieguigang (xie.guigang@live.com) |
| 8 | ' |
| 9 | ' Copyright (c) 2018 GPL3 Licensed |
| 10 | ' |
| 11 | ' |
| 12 | ' GNU GENERAL PUBLIC LICENSE (GPL3) |
| 13 | ' |
| 14 | ' |
| 15 | ' This program is free software: you can redistribute it and/or modify |
| 16 | ' it under the terms of the GNU General Public License as published by |
| 17 | ' the Free Software Foundation, either version 3 of the License, or |
| 18 | ' (at your option) any later version. |
| 19 | ' |
| 20 | ' This program is distributed in the hope that it will be useful, |
| 21 | ' but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | ' GNU General Public License for more details. |
| 24 | ' |
| 25 | ' You should have received a copy of the GNU General Public License |
| 26 | ' along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 27 | |
| 28 | |
| 29 | |
| 30 | ' /********************************************************************************/ |
| 31 | |
| 32 | ' Summaries: |
| 33 | |
| 34 | ' Module NamespaceDocExtensions |
| 35 | ' |
| 36 | ' Function: IsNamespaceDoc, ScanAnnotations |
| 37 | ' |
| 38 | ' |
| 39 | ' /********************************************************************************/ |
| 40 | |
| 41 | #End Region |
| 42 | |
| 43 | Imports System.Runtime.CompilerServices |
| 44 | Imports Microsoft.VisualBasic.ApplicationServices.Development.XmlDoc.Assembly |
| 45 | Imports Microsoft.VisualBasic.Linq |
| 46 | Imports Microsoft.VisualBasic.Text |
| 47 | |
| 48 | Namespace ApplicationServices.Development.XmlDoc.Serialization |
| 49 | |
| 50 | Public Module NamespaceDocExtensions |
| 51 | |
| 52 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
| 53 | <Extension> |
| 54 | Public Function IsNamespaceDoc(type As ProjectType) As Boolean |
| 55 | Return type.Name = APIExtensions.NamespaceDoc |
| 56 | End Function |
| 57 | |
| 58 | ''' <summary> |
| 59 | ''' 一般而言,一个命名空间之下只需要有一个注释类型即可,如果存在多个注释类型的话 |
| 60 | ''' 注释信息字符串会被合并在一起 |
| 61 | ''' </summary> |
| 62 | ''' <param name="project"></param> |
| 63 | ''' <returns></returns> |
| 64 | <Extension> |
| 65 | Public Function ScanAnnotations(project As ProjectSpace) As Dictionary(Of String, String) |
| 66 | Dim annotations = project _ |
| 67 | .Select(Function(proj) proj.Namespaces) _ |
| 68 | .IteratesALL _ |
| 69 | .Select(Function(ns) ns.Types) _ |
| 70 | .IteratesALL _ |
| 71 | .Where(AddressOf IsNamespaceDoc) _ |
| 72 | .GroupBy(Function(doc) doc.Namespace.Path) _ |
| 73 | .ToDictionary(Function(ns) ns.Key, |
| 74 | Function(nsGroup) |
| 75 | Return nsGroup _ |
| 76 | .Select(Function(doc) doc.Summary) _ |
| 77 | .Where(Function(s) Not s.StringEmpty) _ |
| 78 | .Distinct _ |
| 79 | .JoinBy(ASCII.LF & ASCII.LF) |
| 80 | End Function) |
| 81 | Return annotations |
| 82 | End Function |
| 83 | End Module |
| 84 | End Namespace |