DocumentationPage.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
  2. #include "DocumentationPage.h"
  3. #include "ExtDocumentation.h"
  4. TSharedRef< IDocumentationPage > FExtDocumentationPage::Create( const FString& Link, const TSharedRef< FExtUDNParser >& Parser )
  5. {
  6. return MakeShareable( new FExtDocumentationPage( Link, Parser ) );
  7. }
  8. FExtDocumentationPage::~FExtDocumentationPage()
  9. {
  10. }
  11. bool FExtDocumentationPage::GetExcerptContent( FExcerpt& Excerpt )
  12. {
  13. for (int32 Index = 0; Index < StoredExcerpts.Num(); ++Index)
  14. {
  15. if ( Excerpt.Name == StoredExcerpts[ Index ].Name )
  16. {
  17. Parser->GetExcerptContent( Link, StoredExcerpts[ Index ] );
  18. Excerpt.Content = StoredExcerpts[ Index ].Content;
  19. Excerpt.RichText = StoredExcerpts[ Index ].RichText;
  20. return true;
  21. }
  22. }
  23. return false;
  24. }
  25. bool FExtDocumentationPage::HasExcerpt( const FString& ExcerptName )
  26. {
  27. return StoredMetadata.ExcerptNames.Contains( ExcerptName );
  28. }
  29. int32 FExtDocumentationPage::GetNumExcerpts() const
  30. {
  31. return StoredExcerpts.Num();
  32. }
  33. bool FExtDocumentationPage::GetExcerpt(const FString& ExcerptName, FExcerpt& Excerpt)
  34. {
  35. for (const FExcerpt& StoredExcerpt : StoredExcerpts)
  36. {
  37. if (StoredExcerpt.Name == ExcerptName)
  38. {
  39. Excerpt = StoredExcerpt;
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. void FExtDocumentationPage::GetExcerpts( /*OUT*/ TArray< FExcerpt >& Excerpts )
  46. {
  47. Excerpts.Empty();
  48. for (int32 i = 0; i < StoredExcerpts.Num(); ++i)
  49. {
  50. Excerpts.Add(StoredExcerpts[i]);
  51. }
  52. }
  53. FText FExtDocumentationPage::GetTitle()
  54. {
  55. return StoredMetadata.Title;
  56. }
  57. void FExtDocumentationPage::Reload()
  58. {
  59. StoredExcerpts.Empty();
  60. StoredMetadata = FUDNPageMetadata();
  61. Parser->Parse( Link, StoredExcerpts, StoredMetadata );
  62. }
  63. void FExtDocumentationPage::SetTextWrapAt( TAttribute<float> WrapAt )
  64. {
  65. Parser->SetWrapAt( WrapAt );
  66. }
  67. bool FExtDocumentationPage::GetSimpleExcerptContent(FExcerpt& Excerpt)
  68. {
  69. for (int32 Index = 0; Index < StoredExcerpts.Num(); ++Index)
  70. {
  71. if (Excerpt.Name == StoredExcerpts[Index].Name)
  72. {
  73. Parser->GetExcerptContent(Link, StoredExcerpts[Index], /*bInSimpleText*/ true);
  74. Excerpt.Content = StoredExcerpts[Index].Content;
  75. Excerpt.RichText = StoredExcerpts[Index].RichText;
  76. return true;
  77. }
  78. }
  79. return false;
  80. }
  81. FExtDocumentationPage::FExtDocumentationPage( const FString& InLink, const TSharedRef< FExtUDNParser >& InParser )
  82. : Link( InLink )
  83. , Parser( InParser )
  84. {
  85. Parser->Parse( Link, StoredExcerpts, StoredMetadata );
  86. }
  87. #ifdef EXT_DOC_NAMESPACE
  88. #undef EXT_DOC_NAMESPACE
  89. #endif