/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #include "StdAfx.h" #if defined(WIN32) || defined(WIN64) #include "ConsoleHelpGen.h" #include "System.h" // remove bad characters, toupper, not very fast string CConsoleHelpGen::FixAnchorName(const char* szName) { string ret; const char* p = szName; while (*p) { if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9')) { if (*p >= 'a' && *p <= 'z') { ret += *p - 'a' + 'A'; } else { ret += *p; } } ++p; } return ret; } string CConsoleHelpGen::GetCleanPrefix(const char* p) { string sRet; while (*p != '_' && *p != 0) { sRet += *p++; } return sRet; } string CConsoleHelpGen::SplitPrefixString_Part1(const char* p) { string sRet; while (*p != 10 && *p != 13 && *p != 0) { sRet += *p++; } return sRet; } const char* CConsoleHelpGen::SplitPrefixString_Part2(const char* p) { while (*p != 10 && *p != 13 && *p != 0) { p++; } while (*p == 10 || *p == 13) { p++; } return p; } void CConsoleHelpGen::StartPage(FILE* f, const char* szPageName, const char* szPageDescription) const { if (m_eWorkMode == eWM_HTML) { fprintf(f, "
%s
\n", szName);
}
else
{
assert(0);
}
}
void CConsoleHelpGen::EndCVar(FILE* f) const
{
if (m_eWorkMode == eWM_HTML)
{
fprintf(f, "\n");
}
else if (m_eWorkMode == eWM_Confluence)
{
fprintf(f, "
*TODO*\n"); // HTML style } else if (m_eWorkMode == eWM_Confluence) { fprintf(f, "{warning}TODO{warning}\n"); // Confluence style } else { assert(0); } } else { if (m_eWorkMode == eWM_HTML) { fprintf(f, "
\n", szHelp); // HTML style, to get fixed with font (layout in code is often making the assumption the forn is fixed width) } else if (m_eWorkMode == eWM_Confluence) { fprintf(f, "\n%s\n
\n"); string sHelp = szHelp; // currently not required as the {noformat} is used // sHelp.replace("[","\\["); sHelp.replace("]","\\]"); // sHelp.replace("{","\\{"); sHelp.replace("}","\\}"); // sHelp.replace("(","\\("); sHelp.replace(")","\\)"); fprintf(f, "%s\n", sHelp.c_str()); // Confluence style fprintf(f, ""); } else { assert(0); } } EndCVar(f); } void CConsoleHelpGen::Work() { // string sEngineFolder = string("@user@/")+GetFolderName(); // gEnv->pCryPak->RemoveDir(sEngineFolder.c_str()); // todo: check if that works // gEnv->pFileIO->CreatePath(sEngineFolder.c_str()); m_eWorkMode = eWM_HTML; CreateMainPages(); m_eWorkMode = eWM_Confluence; CreateMainPages(); CreateFileForEachEntry(); m_eWorkMode = eWM_None; } void CConsoleHelpGen::CreateFileForEachEntry() { assert(m_eWorkMode == eWM_Confluence); // only needed for confluence // generate a single file for each console command { CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end(); for (itrCmd = m_rParent.m_mapCommands.begin(); itrCmd != itrCmdEnd; ++itrCmd) { const CConsoleCommand& cmd = itrCmd->second; CreateSingleEntryFile(cmd.m_sName.c_str()); } } // generate a single file for each console variable { CXConsole::ConsoleVariablesMap::iterator itrVar, itrVarEnd = m_rParent.m_mapVariables.end(); for (itrVar = m_rParent.m_mapVariables.begin(); itrVar != itrVarEnd; ++itrVar) { ICVar* var = itrVar->second; CreateSingleEntryFile(var->GetName()); } } } void CConsoleHelpGen::CreateMainPages() { gEnv->pFileIO->CreatePath(GetFolderName()); std::map
%s",CXConsole::GetFlagsString(0xffffffff)); // log console variables and commands { StartH3(f2, "Alphabetically Sorted"); std::set
%s