2016-12-08 08:52:44 -05:00
|
|
|
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "Documentation.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "Misc/Paths.h"
|
|
|
|
|
#include "Styling/CoreStyle.h"
|
|
|
|
|
#include "Widgets/SToolTip.h"
|
|
|
|
|
#include "Misc/MessageDialog.h"
|
|
|
|
|
#include "HAL/FileManager.h"
|
|
|
|
|
#include "Misc/CommandLine.h"
|
|
|
|
|
#include "Dialogs/Dialogs.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
#include "SDocumentationAnchor.h"
|
|
|
|
|
#include "UDNParser.h"
|
|
|
|
|
#include "DocumentationPage.h"
|
|
|
|
|
#include "DocumentationLink.h"
|
|
|
|
|
#include "SDocumentationToolTip.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "Interfaces/IAnalyticsProvider.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
#include "EngineAnalytics.h"
|
|
|
|
|
|
2014-09-10 08:49:16 -04:00
|
|
|
#define LOCTEXT_NAMESPACE "DocumentationActor"
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
TSharedRef< IDocumentation > FDocumentation::Create()
|
|
|
|
|
{
|
|
|
|
|
return MakeShareable( new FDocumentation() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FDocumentation::FDocumentation()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FDocumentation::~FDocumentation()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-14 13:15:22 -05:00
|
|
|
bool FDocumentation::OpenHome(FDocumentationSourceInfo Source) const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-01-14 13:15:22 -05:00
|
|
|
return Open( TEXT("%ROOT%"), Source );
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-01-14 13:15:22 -05:00
|
|
|
bool FDocumentation::OpenHome(const FCultureRef& Culture, FDocumentationSourceInfo Source) const
|
2014-04-23 16:43:22 -04:00
|
|
|
{
|
2015-01-14 13:15:22 -05:00
|
|
|
return Open(TEXT("%ROOT%"), Culture, Source);
|
2014-04-23 16:43:22 -04:00
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
bool FDocumentation::OpenAPIHome() const
|
|
|
|
|
{
|
|
|
|
|
FString APIPath = FPaths::Combine(*FPaths::EngineDir(), TEXT("Documentation/CHM/API.chm"));
|
|
|
|
|
if( IFileManager::Get().FileSize( *APIPath ) != INDEX_NONE )
|
|
|
|
|
{
|
|
|
|
|
FString AbsoluteAPIPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*APIPath);
|
|
|
|
|
FPlatformProcess::LaunchFileInDefaultExternalApplication(*AbsoluteAPIPath);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("Documentation", "CannotFindAPIReference", "Cannot open API reference; help file not found."));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-26 12:59:13 -05:00
|
|
|
bool FDocumentation::CanOpenAPIHome() const
|
|
|
|
|
{
|
|
|
|
|
return FPaths::FileExists(FPaths::Combine(*FPaths::EngineDir(), TEXT("Documentation/CHM/API.chm")));
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-14 13:15:22 -05:00
|
|
|
bool FDocumentation::Open(const FString& Link, FDocumentationSourceInfo Source) const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
FString DocumentationUrl;
|
|
|
|
|
|
2014-09-10 08:49:16 -04:00
|
|
|
// Warn the user if they are opening a URL
|
|
|
|
|
if (Link.StartsWith(TEXT("http")) || Link.StartsWith(TEXT("https")))
|
|
|
|
|
{
|
|
|
|
|
FText Message = LOCTEXT("OpeningURLMessage", "You are about to open an external URL. This will open your web browser. Do you want to proceed?");
|
|
|
|
|
FText URLDialog = LOCTEXT("OpeningURLTitle", "Open external link");
|
|
|
|
|
|
2016-02-04 10:55:30 -05:00
|
|
|
FSuppressableWarningDialog::FSetupInfo Info(Message, URLDialog, "SuppressOpenURLWarning");
|
2014-09-10 08:49:16 -04:00
|
|
|
Info.ConfirmText = LOCTEXT("OpenURL_yes", "Yes");
|
|
|
|
|
Info.CancelText = LOCTEXT("OpenURL_no", "No");
|
|
|
|
|
FSuppressableWarningDialog OpenURLWarning(Info);
|
|
|
|
|
if (OpenURLWarning.ShowModal() == FSuppressableWarningDialog::Cancel)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FPlatformProcess::LaunchURL(*Link, nullptr, nullptr);
|
2014-10-02 05:28:25 -04:00
|
|
|
return true;
|
2014-09-10 08:49:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-23 16:43:22 -04:00
|
|
|
if (!FParse::Param(FCommandLine::Get(), TEXT("testdocs")))
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-04-23 16:43:22 -04:00
|
|
|
FString OnDiskPath = FDocumentationLink::ToFilePath(Link);
|
2014-03-14 14:13:41 -04:00
|
|
|
if (IFileManager::Get().FileSize(*OnDiskPath) != INDEX_NONE)
|
|
|
|
|
{
|
2015-01-14 13:15:22 -05:00
|
|
|
DocumentationUrl = FDocumentationLink::ToFileUrl(Link, Source);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-10 08:49:16 -04:00
|
|
|
|
2014-04-23 16:43:22 -04:00
|
|
|
if (DocumentationUrl.IsEmpty())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-04-23 16:43:22 -04:00
|
|
|
// When opening a doc website we always request the most ideal culture for our documentation.
|
|
|
|
|
// The DNS will redirect us if necessary.
|
2015-01-14 13:15:22 -05:00
|
|
|
DocumentationUrl = FDocumentationLink::ToUrl(Link, Source);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-04-23 16:43:22 -04:00
|
|
|
if (!DocumentationUrl.IsEmpty())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-04-23 16:43:22 -04:00
|
|
|
FPlatformProcess::LaunchURL(*DocumentationUrl, NULL, NULL);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-04-23 16:43:22 -04:00
|
|
|
if (!DocumentationUrl.IsEmpty() && FEngineAnalytics::IsAvailable())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-04-23 16:43:22 -04:00
|
|
|
FEngineAnalytics::GetProvider().RecordEvent(TEXT("Editor.Usage.Documentation"), TEXT("OpenedPage"), Link);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
2014-04-23 16:43:22 -04:00
|
|
|
|
|
|
|
|
return !DocumentationUrl.IsEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-14 13:15:22 -05:00
|
|
|
bool FDocumentation::Open(const FString& Link, const FCultureRef& Culture, FDocumentationSourceInfo Source) const
|
2014-04-23 16:43:22 -04:00
|
|
|
{
|
|
|
|
|
FString DocumentationUrl;
|
|
|
|
|
|
|
|
|
|
if (!FParse::Param(FCommandLine::Get(), TEXT("testdocs")))
|
|
|
|
|
{
|
|
|
|
|
FString OnDiskPath = FDocumentationLink::ToFilePath(Link, Culture);
|
|
|
|
|
if (IFileManager::Get().FileSize(*OnDiskPath) != INDEX_NONE)
|
|
|
|
|
{
|
2015-01-14 13:15:22 -05:00
|
|
|
DocumentationUrl = FDocumentationLink::ToFileUrl(Link, Culture, Source);
|
2014-04-23 16:43:22 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (DocumentationUrl.IsEmpty())
|
|
|
|
|
{
|
2015-01-14 13:15:22 -05:00
|
|
|
DocumentationUrl = FDocumentationLink::ToUrl(Link, Culture, Source);
|
2014-04-23 16:43:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!DocumentationUrl.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
FPlatformProcess::LaunchURL(*DocumentationUrl, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!DocumentationUrl.IsEmpty() && FEngineAnalytics::IsAvailable())
|
|
|
|
|
{
|
|
|
|
|
FEngineAnalytics::GetProvider().RecordEvent(TEXT("Editor.Usage.Documentation"), TEXT("OpenedPage"), Link);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
return !DocumentationUrl.IsEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-21 17:31:27 -04:00
|
|
|
TSharedRef< SWidget > FDocumentation::CreateAnchor( const TAttribute<FString>& Link, const FString& PreviewLink, const FString& PreviewExcerptName ) const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-07-21 17:31:27 -04:00
|
|
|
return SNew( SDocumentationAnchor )
|
|
|
|
|
.Link(Link)
|
2014-03-14 14:13:41 -04:00
|
|
|
.PreviewLink(PreviewLink)
|
|
|
|
|
.PreviewExcerptName(PreviewExcerptName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef< IDocumentationPage > FDocumentation::GetPage( const FString& Link, const TSharedPtr< FParserConfiguration >& Config, const FDocumentationStyle& Style )
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr< IDocumentationPage > Page;
|
|
|
|
|
const TWeakPtr< IDocumentationPage >* ExistingPagePtr = LoadedPages.Find( Link );
|
|
|
|
|
|
|
|
|
|
if ( ExistingPagePtr != NULL )
|
|
|
|
|
{
|
|
|
|
|
const TSharedPtr< IDocumentationPage > ExistingPage = ExistingPagePtr->Pin();
|
|
|
|
|
if ( ExistingPage.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
Page = ExistingPage;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !Page.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
Page = FDocumentationPage::Create( Link, FUDNParser::Create( Config, Style ) );
|
|
|
|
|
LoadedPages.Add( Link, TWeakPtr< IDocumentationPage >( Page ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Page.ToSharedRef();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FDocumentation::PageExists(const FString& Link) const
|
|
|
|
|
{
|
|
|
|
|
const TWeakPtr< IDocumentationPage >* ExistingPagePtr = LoadedPages.Find(Link);
|
|
|
|
|
if (ExistingPagePtr != NULL)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-23 16:43:22 -04:00
|
|
|
const FString SourcePath = FDocumentationLink::ToSourcePath(Link);
|
|
|
|
|
return FPaths::FileExists(SourcePath);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-13 17:14:52 -04:00
|
|
|
bool FDocumentation::PageExists(const FString& Link, const FCultureRef& Culture) const
|
2014-04-23 16:43:22 -04:00
|
|
|
{
|
|
|
|
|
const TWeakPtr< IDocumentationPage >* ExistingPagePtr = LoadedPages.Find(Link);
|
|
|
|
|
if (ExistingPagePtr != NULL)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FString SourcePath = FDocumentationLink::ToSourcePath(Link, Culture);
|
|
|
|
|
return FPaths::FileExists(SourcePath);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-01-26 18:13:04 -05:00
|
|
|
TSharedRef< class SToolTip > FDocumentation::CreateToolTip(const TAttribute<FText>& Text, const TSharedPtr<SWidget>& OverrideContent, const FString& Link, const FString& ExcerptName) const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
TSharedPtr< SDocumentationToolTip > DocToolTip;
|
|
|
|
|
|
|
|
|
|
if ( !Text.IsBound() && Text.Get().IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
return SNew( SToolTip );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( OverrideContent.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
SAssignNew( DocToolTip, SDocumentationToolTip )
|
|
|
|
|
.DocumentationLink( Link )
|
|
|
|
|
.ExcerptName( ExcerptName )
|
|
|
|
|
[
|
|
|
|
|
OverrideContent.ToSharedRef()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SAssignNew( DocToolTip, SDocumentationToolTip )
|
|
|
|
|
.Text( Text )
|
|
|
|
|
.DocumentationLink( Link )
|
|
|
|
|
.ExcerptName( ExcerptName );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SNew( SToolTip )
|
|
|
|
|
.IsInteractive( DocToolTip.ToSharedRef(), &SDocumentationToolTip::IsInteractive )
|
2015-01-26 18:59:35 -05:00
|
|
|
|
|
|
|
|
// Emulate text-only tool-tip styling that SToolTip uses when no custom content is supplied. We want documentation tool-tips to
|
|
|
|
|
// be styled just like text-only tool-tips
|
|
|
|
|
.BorderImage( FCoreStyle::Get().GetBrush("ToolTip.BrightBackground") )
|
|
|
|
|
.TextMargin(FMargin(11.0f))
|
2014-03-14 14:13:41 -04:00
|
|
|
[
|
|
|
|
|
DocToolTip.ToSharedRef()
|
|
|
|
|
];
|
2014-09-10 08:49:16 -04:00
|
|
|
}
|
|
|
|
|
|
2015-01-26 18:13:04 -05:00
|
|
|
TSharedRef< class SToolTip > FDocumentation::CreateToolTip(const TAttribute<FText>& Text, const TSharedRef<SWidget>& OverrideContent, const TSharedPtr<SVerticalBox>& DocVerticalBox, const FString& Link, const FString& ExcerptName) const
|
|
|
|
|
{
|
|
|
|
|
TSharedRef<SDocumentationToolTip> DocToolTip =
|
|
|
|
|
SNew(SDocumentationToolTip)
|
|
|
|
|
.Text(Text)
|
|
|
|
|
.DocumentationLink(Link)
|
|
|
|
|
.ExcerptName(ExcerptName)
|
|
|
|
|
.AddDocumentation(false)
|
|
|
|
|
.DocumentationMargin(7)
|
|
|
|
|
[
|
|
|
|
|
OverrideContent
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (DocVerticalBox.IsValid())
|
|
|
|
|
{
|
|
|
|
|
DocToolTip->AddDocumentation(DocVerticalBox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SNew(SToolTip)
|
|
|
|
|
.IsInteractive(DocToolTip, &SDocumentationToolTip::IsInteractive)
|
2015-01-30 10:55:24 -05:00
|
|
|
|
|
|
|
|
// Emulate text-only tool-tip styling that SToolTip uses when no custom content is supplied. We want documentation tool-tips to
|
|
|
|
|
// be styled just like text-only tool-tips
|
|
|
|
|
.BorderImage( FCoreStyle::Get().GetBrush("ToolTip.BrightBackground") )
|
|
|
|
|
.TextMargin(FMargin(11.0f))
|
2015-01-26 18:13:04 -05:00
|
|
|
[
|
|
|
|
|
DocToolTip
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-10 08:49:16 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE
|