Merging the Help module (#11008)

* Adding the Help module - fixes 10527, fixes #10512

* Aded Help to pre-commit

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Yorik van Havre
2023-10-16 18:17:06 +02:00
committed by GitHub
parent e2844f791e
commit 31b0896cf0
14 changed files with 1252 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ files: |
src/Mod/Drawing|
src/Mod/Fem/App|
src/Mod/Fem/Gui|
src/Mod/Help|
src/Mod/Import|
src/Mod/Inspection|
src/Mod/JtReader|

View File

@@ -106,6 +106,7 @@ macro(InitializeFreeCADBuildOptions)
option(BUILD_ARCH "Build the FreeCAD Architecture module" ON)
option(BUILD_DRAFT "Build the FreeCAD draft module" ON)
option(BUILD_DRAWING "Build the FreeCAD drawing module" OFF)
option(BUILD_HELP "Build the FreeCAD help module" ON)
option(BUILD_IDF "Build the FreeCAD idf module" ON)
option(BUILD_IMPORT "Build the FreeCAD import module" ON)
option(BUILD_INSPECTION "Build the FreeCAD inspection module" ON)

View File

@@ -26,6 +26,10 @@ if(BUILD_FEM)
add_subdirectory(Fem)
endif(BUILD_FEM)
if(BUILD_HELP)
add_subdirectory(Help)
endif(BUILD_HELP)
if(BUILD_IDF)
add_subdirectory(Idf)
endif(BUILD_IDF)

View File

@@ -0,0 +1,25 @@
IF (BUILD_GUI)
PYSIDE_WRAP_RC(Help_QRC_SRCS Resources/Help.qrc)
ENDIF (BUILD_GUI)
SET(Help_SRCS
InitGui.py
default.css
Help.py
dlgPreferencesHelp.ui
)
SOURCE_GROUP("" FILES ${Help_SRCS})
ADD_CUSTOM_TARGET(Help ALL SOURCES ${Help_SRCS} ${Help_QRC_SRCS})
fc_copy_sources(Help "${CMAKE_BINARY_DIR}/Mod/Help" ${Help_SRCS})
IF (BUILD_GUI)
fc_target_copy_resource(Help
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}/Mod/Help
Help_rc.py)
ENDIF (BUILD_GUI)
INSTALL(FILES ${Help_SRCS} ${Help_QRC_SRCS} DESTINATION Mod/Help)

463
src/Mod/Help/Help.py Normal file
View File

@@ -0,0 +1,463 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * Copyright (c) 2021 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
"""
Provide tools to access the FreeCAD documentation.
The main usage is using the "show" function. It can retrieve an URL,
a local file (markdown or html), or find a page automatically from
the settings set under Preferences->General->Help.
It doesn't matter what you give, the system will recognize if the contents are
HTML or Markdown and render it appropriately.
Basic usage:
import Help
Help.show("Draft Line")
Help.show("Draft_Line") # works with spaces or underscores
Help.show("https://wiki.freecadweb.org/Draft_Line")
Help.show("https://gitlab.com/freecad/FreeCAD-documentation/-/raw/main/wiki/Draft_Line.md")
Help.show("/home/myUser/.FreeCAD/Documentation/Draft_Line.md")
Help.show("http://myserver.com/myfolder/Draft_Line.html")
Preferences keys (in "User parameter:BaseApp/Preferences/Mod/Help"):
optionBrowser/optionTab/optionDialog (bool): Where to open the help dialog
optionOnline/optionOffline (bool): where to fetch the documentation from
URL (string): online location
Location (string): offline location
Suffix (string): a suffix to add to the URL, ex: /fr
StyleSheet (string): optional CSS stylesheet to style the output
"""
import os
import FreeCAD
translate = FreeCAD.Qt.translate
QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP
# texts and icons
WIKI_URL = "https://wiki.freecad.org"
MD_RAW_URL = "https://raw.githubusercontent.com/FreeCAD/FreeCAD-documentation/main/wiki"
MD_RENDERED_URL = "https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki"
MD_TRANSLATIONS_FOLDER = "translations"
ERRORTXT = translate(
"Help",
"Contents for this page could not be retrieved. Please check settings under menu Edit -> Preferences -> General -> Help",
)
LOCTXT = translate(
"Help",
"Help files location could not be determined. Please check settings under menu Edit -> Preferences -> General -> Help",
)
LOGTXT = translate(
"Help",
"PySide QtWebEngineWidgets module is not available. Help rendering is done with the Web module",
)
CONVERTTXT = translate(
"Help",
"There is no markdown renderer installed on your system, so this help page is rendered as is. Please install the markdown or pandoc python modules to improve the rendering of this page.",
)
PREFS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Help")
ICON = ":/icons/help-browser.svg"
def show(page, view=None, conv=None):
"""
show(page,view=None, conv=None):
Opens a help viewer and shows the given help page.
The given help page can be a URL pointing to a markdown or HTML file,
a name page / command name, or a file path pointing to a markdown
or HTML file. If view is given (an instance of openBrowserHTML.HelpPage or
any other object with a 'setHtml()' method), the page will be
rendered there, otherwise a new tab/widget will be created according to
preferences settings. If conv is given (markdown, pandoc, github, builtin or
none), the corresponding markdown conversion method is used. Otherwise, the
module will use the best available.
In non-GUI mode, this function simply outputs the markdown or HTML text.
"""
page = underscore_page(page)
location = get_location(page)
FreeCAD.Console.PrintLog("Help: opening " + location + "\n")
if not location:
FreeCAD.Console.PrintError(LOCTXT + "\n")
return
md = get_contents(location)
html = convert(md, conv)
baseurl = get_uri(location)
pagename = os.path.basename(page.replace("_", " ").replace(".md", ""))
title = translate("Help", "Help") + ": " + pagename
if FreeCAD.GuiUp:
if PREFS.GetBool("optionBrowser", False): # desktop web browser
show_browser(location)
elif PREFS.GetBool("optionDialog", False): # floating dock window
show_dialog(html, baseurl, title, view)
else: # MDI tab - default
show_tab(html, baseurl, title, view)
else:
# console mode, we just print the output
print(md)
def underscore_page(page):
"""change spaces by underscores in the given page name"""
if "/" in page:
page = page.split("/")
page[-1] = page[-1].replace(" ", "_")
page = "/".join(page)
else:
page.replace(" ", "_")
return page
def get_uri(location):
"""returns a valid URI from a disk or network location"""
baseurl = os.path.dirname(location) + "/"
if baseurl.startswith("/"): # unix path
baseurl = "file://" + baseurl
if baseurl[0].isupper() and (baseurl[1] == ":"): # windows path
baseurl = baseurl.replace("\\", "/")
baseurl = "file:///" + baseurl
return baseurl
def get_location(page):
"""retrieves the location (online or offline) of a given page"""
location = ""
if page.startswith("http"):
return page
if page.startswith("file://"):
return page[7:]
# offline location
if os.path.exists(page):
return page
page = page.replace(".md", "")
page = page.replace(" ", "_")
page = page.replace("wiki/", "")
page = page.split("#")[0]
suffix = PREFS.GetString("Suffix", "")
if suffix:
if not suffix.startswith("/"):
suffix = "/" + suffix
if PREFS.GetBool("optionWiki", True): # default
location = WIKI_URL + "/" + page + suffix
elif PREFS.GetBool("optionMarkdown", False):
if PREFS.GetBool("optionBrowser", False):
location = MD_RENDERED_URL
else:
location = MD_RAW_URL
if suffix:
location += "/" + MD_TRANSLATIONS_FOLDER + suffix
location += "/" + page + ".md"
elif PREFS.GetBool("optionGithub", False):
location = MD_RENDERED_URL
if suffix:
location += "/" + MD_TRANSLATIONS_FOLDER + suffix
location += "/" + page + ".md"
elif PREFS.GetBool("optionCustom", False):
location = PREFS.GetString("Location", "")
if not location:
location = os.path.join(FreeCAD.getUserAppDataDir(), "Mod", "Documentation", "wiki")
location += page + "md"
return location
def show_browser(url):
"""opens the desktop browser with the given URL"""
from PySide import QtCore, QtGui
try:
ret = QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
if not ret:
# some users reported problems with the above
import webbrowser
webbrowser.open_new(url)
except:
import webbrowser
webbrowser.open_new(url)
def show_dialog(html, baseurl, title, view=None):
"""opens a dock dialog with the given html"""
from PySide import QtCore
if get_qtwebwidgets(html, baseurl, title):
if view: # reusing existing view
view.setHtml(html, baseUrl=QtCore.QUrl(baseurl))
view.parent().parent().setWindowTitle(title)
else:
openBrowserHTML(html, baseurl, title, ICON, dialog=True)
def show_tab(html, baseurl, title, view=None):
"""opens a MDI tab with the given html"""
from PySide import QtCore
if get_qtwebwidgets(html, baseurl, title):
if view: # reusing existing view
view.setHtml(html, baseUrl=QtCore.QUrl(baseurl))
view.parent().parent().setWindowTitle(title)
else:
# the line below causes a crash with current Qt5 version
# openBrowserHTML(html,baseurl,title,ICON)
# so ATM we use the WebGui browser instead
import WebGui
WebGui.openBrowserHTML(html, baseurl, title, ICON)
def get_qtwebwidgets(html, baseurl, title):
"""opens a web module view if qtwebwidgets module is not available, and returns False"""
try:
from PySide import QtGui, QtWebEngineWidgets
except:
FreeCAD.Console.PrintLog(LOGTXT + "\n")
import WebGui
WebGui.openBrowserHTML(html, baseurl, title, ICON)
return False
else:
return True
def get_contents(location):
"""retrieves text contents of a given page"""
import urllib
if location.startswith("http"):
import urllib.request
try:
r = urllib.request.urlopen(location)
except:
return ERRORTXT
contents = r.read().decode("utf8")
return contents
else:
if os.path.exists(location):
with open(location, mode="r", encoding="utf8") as f:
contents = f.read()
return contents
return ERRORTXT
def convert(content, force=None):
"""converts the given markdown code to html. Force can be None (automatic)
or markdown, pandoc, github or raw/builtin"""
import urllib
def convert_markdown(m):
try:
import markdown
from markdown.extensions import codehilite
return markdown.markdown(m, extensions=["codehilite"])
except:
return None
def convert_pandoc(m):
try:
import pypandoc
return pypandoc.convert_text(m, "html", format="md")
except:
return None
def convert_github(m):
try:
import json
import urllib.request
data = {"text": m, "mode": "markdown"}
bdata = json.dumps(data).encode("utf-8")
return (
urllib.request.urlopen("https://api.github.com/markdown", data=bdata)
.read()
.decode("utf8")
)
except:
return None
def convert_raw(m):
# simple and dirty regex-based markdown to html
import re
f = re.DOTALL | re.MULTILINE
m = re.sub(r"^##### (.*?)\n", r"<h5>\1</h5>\n", m, flags=f) # ##### titles
m = re.sub(r"^#### (.*?)\n", r"<h4>\1</h4>\n", m, flags=f) # #### titles
m = re.sub(r"^### (.*?)\n", r"<h3>\1</h3>\n", m, flags=f) # ### titles
m = re.sub(r"^## (.*?)\n", r"<h2>\1</h2>\n", m, flags=f) # ## titles
m = re.sub(r"^# (.*?)\n", r"<h1>\1</h1>\n", m, flags=f) # # titles
m = re.sub(r"!\[(.*?)\]\((.*?)\)", r'<img alt="\1" src="\2">', m, flags=f) # images
m = re.sub(r"\[(.*?)\]\((.*?)\)", r'<a href="\2">\1</a>', m, flags=f) # links
m = re.sub(r"\*\*(.*?)\*\*", r"<b>\1</b>", m) # bold
m = re.sub(r"\*(.*?)\*", r"<i>\1</i>", m) # italic
m = re.sub(r"\n\n", r"<br/>", m, flags=f) # double new lines
m += "\n<br/><hr/><small>" + CONVERTTXT + "</small>"
return m
if "<html" in content:
# this is html already
return content
if force == "markdown":
html = convert_markdown(content)
elif force == "pandoc":
html = convert_pandoc(content)
elif force == "github":
html = convert_github(content)
elif force in ["raw", "builtin"]:
html = convert_raw(content)
elif force == "none":
return content
else:
# auto mode
html = convert_pandoc(content)
if not html:
html = convert_markdown(content)
if not html:
html = convert_raw(content)
if not "<html" in html:
html = (
'<html>\n<head>\n<meta charset="utf-8"/>\n</head>\n<body>\n\n'
+ html
+ "</body>\n</html>"
)
# insert css
css = None
cssfile = PREFS.GetString("StyleSheet", "")
if not cssfile:
cssfile = os.path.join(os.path.dirname(__file__), "default.css")
if False: # linked CSS file
# below code doesn't work in FreeCAD apparently because it prohibits cross-URL stuff
cssfile = urllib.parse.urljoin("file:", urllib.request.pathname2url(cssfile))
css = '<link rel="stylesheet" type="text/css" href="' + cssfile + '"/>'
else:
if os.path.exists(cssfile):
with open(cssfile) as cf:
css = cf.read()
if css:
css = "<style>\n" + css + "\n</style>"
else:
print("Debug: Help: Unable to open css file:", cssfile)
if css:
html = html.replace("</head>", css + "\n</head>")
return html
def add_preferences_page():
"""adds the Help preferences page to the UI"""
import FreeCADGui
page = os.path.join(os.path.dirname(__file__), "dlgPreferencesHelp.ui")
FreeCADGui.addPreferencePage(page, QT_TRANSLATE_NOOP("QObject", "General"))
def add_language_path():
"""registers the Help translations to FreeCAD"""
import FreeCADGui
import Help_rc
FreeCADGui.addLanguagePath(":/translations")
def openBrowserHTML(html, baseurl, title, icon, dialog=False):
"""creates a browser view and adds it as a FreeCAD MDI tab or dockable dialog"""
import FreeCADGui
from PySide import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
# turn an int into a qt dock area
def getDockArea(area):
if area == 1:
return QtCore.Qt.LeftDockWidgetArea
elif area == 4:
return QtCore.Qt.TopDockWidgetArea
elif area == 8:
return QtCore.Qt.BottomDockWidgetArea
else:
return QtCore.Qt.RightDockWidgetArea
# save dock widget size and location
def onDockLocationChanged(area):
PREFS.SetInt("dockWidgetArea", int(area))
mw = FreeCADGui.getMainWindow()
dock = mw.findChild(QtWidgets.QDockWidget, "HelpWidget")
if dock:
PREFS.SetBool("dockWidgetFloat", dock.isFloating())
PREFS.SetInt("dockWidgetWidth", dock.width())
PREFS.SetInt("dockWidgetHeight", dock.height())
# a custom page that handles .md links
class HelpPage(QtWebEngineWidgets.QWebEnginePage):
def acceptNavigationRequest(self, url, _type, isMainFrame):
if _type == QtWebEngineWidgets.QWebEnginePage.NavigationTypeLinkClicked:
show(url.toString(), view=self)
return super().acceptNavigationRequest(url, _type, isMainFrame)
mw = FreeCADGui.getMainWindow()
view = QtWebEngineWidgets.QWebEngineView()
page = HelpPage(None, view)
page.setHtml(html, baseUrl=QtCore.QUrl(baseurl))
view.setPage(page)
if dialog:
area = PREFS.GetInt("dockWidgetArea", 2)
floating = PREFS.GetBool("dockWidgetFloat", True)
height = PREFS.GetBool("dockWidgetWidth", 200)
width = PREFS.GetBool("dockWidgetHeight", 300)
dock = mw.findChild(QtWidgets.QDockWidget, "HelpWidget")
if not dock:
dock = QtWidgets.QDockWidget()
dock.setObjectName("HelpWidget")
mw.addDockWidget(getDockArea(area), dock)
dock.setFloating(floating)
dock.setGeometry(dock.x(), dock.y(), width, height)
dock.dockLocationChanged.connect(onDockLocationChanged)
dock.setWidget(view)
dock.setWindowTitle(title)
dock.setWindowIcon(QtGui.QIcon(icon))
dock.show()
else:
mdi = mw.findChild(QtWidgets.QMdiArea)
sw = mdi.addSubWindow(view)
sw.setWindowTitle(title)
sw.setWindowIcon(QtGui.QIcon(icon))
sw.show()
mdi.setActiveSubWindow(sw)

27
src/Mod/Help/InitGui.py Normal file
View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * Copyright (c) 2021 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
import Help
Help.add_preferences_page()
Help.add_language_path()

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource>
<file>translations/Help_en.qm</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,210 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>Form</name>
<message>
<location filename="../dlgPreferencesHelp.ui" line="14"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="20"/>
<source>Source</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="29"/>
<source>This will fetch the documentation from pages rendered on github. This is currently not available...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="32"/>
<source>Github (online)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="45"/>
<location filename="../dlgPreferencesHelp.ui" line="80"/>
<source>Set this to a custom URL or the folder where the help files are located. You can easily download the documentation for offline use by using the Addon Manager and installing the &quot;offline documentation&quot; addon. If this field is left blank, FreeCAD will automatically search for the help files at the default location ($USERAPPDATADIR/Mod/Documentation).</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="48"/>
<source>Custom location</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="67"/>
<source>A translation suffix to use, for example &quot;fr&quot; to get French translation of the documentation.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="99"/>
<source> Translation suffix:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="106"/>
<source>The documentation pages will be fetched from the official FreeCADwiki at https://wiki.freecad.org</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="109"/>
<source>FreeCAD Wiki (online)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="125"/>
<source>The documentation pages will be fetched from an automatic markdown conversion of the FreeCAD wiki, hosted on FreeCAD&apos;s github account. This can be styled with a custom stylesheet below and can look nicer than the wiki option. The &apos;markdown&apos; or &apos;pandoc&apos; python module should be installed for optimal results.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="128"/>
<source>Markdown version (online)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="147"/>
<source>Display</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="153"/>
<source>The documentation will open in a new tab inside the FreeCAD interface.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="156"/>
<source>In a FreeCAD tab</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="172"/>
<source>The documentation will open in your default desktop browser.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="175"/>
<source>In your default web browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="191"/>
<source>The documentation will open in a dockable dialog inside the FreeCAD window, which allows you to keep it open whlle working in the 3D view.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="194"/>
<source>In a separate, embeddable dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="210"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="218"/>
<source> Custom stylesheet:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="225"/>
<source>You can here indicate the path to an alternative CSS file to be used to style the markdown pages. This will only work if you have selected the Markdown version above.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Help</name>
<message>
<location filename="../Help.py" line="69"/>
<source>Contents for this page could not be retrieved. Please check settings under menu Edit -&gt; Preferences -&gt; General -&gt; Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../Help.py" line="70"/>
<source>Help files location could not be determined. Please check settings under menu Edit -&gt; Preferences -&gt; General -&gt; Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../Help.py" line="71"/>
<source>PySide2 QtWebEngineWidgets module is not available. Help rendering is done with the Web module</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../Help.py" line="72"/>
<source>There is no markdown renderer installed on your system, so this help page is rendered as is. Please install the markdown or pandoc python modules to improve the rendering of this page.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../Help.py" line="104"/>
<location filename="../MenuUtils.py" line="87"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="30"/>
<source>Home</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="31"/>
<source>Forum</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="32"/>
<source>Wiki</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="33"/>
<source>Issues</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="34"/>
<source>Code repository</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="36"/>
<source>Auto Python modules</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="37"/>
<source>About FreeCAD</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="38"/>
<source>What&apos;s this?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="91"/>
<source>On the web</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="104"/>
<source>Documentation</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="107"/>
<source>Shows the index page of the FreeCAD documentation</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../Help.py" line="372"/>
<source>General</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@@ -0,0 +1,210 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>Form</name>
<message>
<location filename="../dlgPreferencesHelp.ui" line="14"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="20"/>
<source>Source</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="29"/>
<source>This will fetch the documentation from pages rendered on github. This is currently not available...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="32"/>
<source>Github (online)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="45"/>
<location filename="../dlgPreferencesHelp.ui" line="80"/>
<source>Set this to a custom URL or the folder where the help files are located. You can easily download the documentation for offline use by using the Addon Manager and installing the &quot;offline documentation&quot; addon. If this field is left blank, FreeCAD will automatically search for the help files at the default location ($USERAPPDATADIR/Mod/Documentation).</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="48"/>
<source>Custom location</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="67"/>
<source>A translation suffix to use, for example &quot;fr&quot; to get French translation of the documentation.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="99"/>
<source> Translation suffix:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="106"/>
<source>The documentation pages will be fetched from the official FreeCADwiki at https://wiki.freecad.org</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="109"/>
<source>FreeCAD Wiki (online)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="125"/>
<source>The documentation pages will be fetched from an automatic markdown conversion of the FreeCAD wiki, hosted on FreeCAD&apos;s github account. This can be styled with a custom stylesheet below and can look nicer than the wiki option. The &apos;markdown&apos; or &apos;pandoc&apos; python module should be installed for optimal results.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="128"/>
<source>Markdown version (online)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="147"/>
<source>Display</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="153"/>
<source>The documentation will open in a new tab inside the FreeCAD interface.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="156"/>
<source>In a FreeCAD tab</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="172"/>
<source>The documentation will open in your default desktop browser.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="175"/>
<source>In your default web browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="191"/>
<source>The documentation will open in a dockable dialog inside the FreeCAD window, which allows you to keep it open whlle working in the 3D view.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="194"/>
<source>In a separate, embeddable dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="210"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="218"/>
<source> Custom stylesheet:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dlgPreferencesHelp.ui" line="225"/>
<source>You can here indicate the path to an alternative CSS file to be used to style the markdown pages. This will only work if you have selected the Markdown version above.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Help</name>
<message>
<location filename="../Help.py" line="69"/>
<source>Contents for this page could not be retrieved. Please check settings under menu Edit -&gt; Preferences -&gt; General -&gt; Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../Help.py" line="70"/>
<source>Help files location could not be determined. Please check settings under menu Edit -&gt; Preferences -&gt; General -&gt; Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../Help.py" line="71"/>
<source>PySide2 QtWebEngineWidgets module is not available. Help rendering is done with the Web module</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../Help.py" line="72"/>
<source>There is no markdown renderer installed on your system, so this help page is rendered as is. Please install the markdown or pandoc python modules to improve the rendering of this page.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../Help.py" line="104"/>
<location filename="../MenuUtils.py" line="87"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="30"/>
<source>Home</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="31"/>
<source>Forum</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="32"/>
<source>Wiki</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="33"/>
<source>Issues</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="34"/>
<source>Code repository</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="36"/>
<source>Auto Python modules</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="37"/>
<source>About FreeCAD</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="38"/>
<source>What&apos;s this?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="91"/>
<source>On the web</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="104"/>
<source>Documentation</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MenuUtils.py" line="107"/>
<source>Shows the index page of the FreeCAD documentation</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../Help.py" line="372"/>
<source>General</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

19
src/Mod/Help/default.css Normal file
View File

@@ -0,0 +1,19 @@
/* our own FreeCAD styling */
html { color: #000000; font-family: "sans"; background: #ffffff; }
a { color: #3071B1; font-weight: bold; }
body { max-width: 800px; text-align: justify; margin:10px auto; padding: 10px; }
img { max-width: 100%; margin: 10px 0; }
li { padding: 5px 0; }
li img { vertical-align:middle; margin: 0; }
pre, code { background: #eeeeee; white-space: pre-wrap; }
pre { padding: 10px; }
code { padding: 2px 5px; }
h1, h2, h3, h4, h5 { margin: 25px 0; color: #222222; }
h1 { border-bottom: 1px solid #000000; }
/* codehilite */
.dv { color: #9A0000; } /* numbers */
.im { color: #0A1F96; font-weight: bold; } /* import */
.op { color: #333333; } /* operators */

View File

@@ -0,0 +1,279 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>549</height>
</rect>
</property>
<property name="windowTitle">
<string>Help</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Source</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="Gui::PrefRadioButton" name="radioButton_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>This will fetch the documentation from pages rendered on github. This is currently not available...</string>
</property>
<property name="text">
<string>Github (online)</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>optionGithub</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="Gui::PrefRadioButton" name="radioOffline">
<property name="toolTip">
<string>Set this to a custom URL or the folder where the help files are located. You can easily download the documentation for offline use by using the Addon Manager and installing the &quot;offline documentation&quot; addon. If this field is left blank, FreeCAD will automatically search for the help files at the default location ($USERAPPDATADIR/Mod/Documentation).</string>
</property>
<property name="text">
<string>Custom location</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>optionCustom</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Gui::PrefLineEdit" name="lineEdit_2">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>A translation suffix to use, for example &quot;fr&quot; to get French translation of the documentation.</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>Suffix</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="Gui::PrefFileChooser" name="fileChooser">
<property name="toolTip">
<string>Set this to a custom URL or the folder where the help files are located. You can easily download the documentation for offline use by using the Addon Manager and installing the &quot;offline documentation&quot; addon. If this field is left blank, FreeCAD will automatically search for the help files at the default location ($USERAPPDATADIR/Mod/Documentation).</string>
</property>
<property name="fileName">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>Location</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string> Translation suffix:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="Gui::PrefRadioButton" name="radioButton">
<property name="toolTip">
<string>The documentation pages will be fetched from the official FreeCADwiki at https://wiki.freecad.org</string>
</property>
<property name="text">
<string>FreeCAD Wiki (online)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>optionWiki</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefRadioButton" name="radioOnline">
<property name="toolTip">
<string>The documentation pages will be fetched from an automatic markdown conversion of the FreeCAD wiki, hosted on FreeCAD's github account. This can be styled with a custom stylesheet below and can look nicer than the wiki option. The 'markdown' or 'pandoc' python module should be installed for optimal results.</string>
</property>
<property name="text">
<string>Markdown version (online)</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>optionMarkdown</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Display</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="Gui::PrefRadioButton" name="radioTab">
<property name="toolTip">
<string>The documentation will open in a new tab inside the FreeCAD interface.</string>
</property>
<property name="text">
<string>In a FreeCAD tab</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>optionTab</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefRadioButton" name="radioBrowser">
<property name="toolTip">
<string>The documentation will open in your default desktop browser.</string>
</property>
<property name="text">
<string>In your default web browser</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>optionBrowser</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefRadioButton" name="radioDialog">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>The documentation will open in a dockable dialog inside the FreeCAD window, which allows you to keep it open whlle working in the 3D view.</string>
</property>
<property name="text">
<string>In a separate, embeddable dialog</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>optionDialog</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string> Custom stylesheet:</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefFileChooser" name="styleSheet">
<property name="toolTip">
<string>You can here indicate the path to an alternative CSS file to be used to style the markdown pages. This will only work if you have selected the Markdown version above.</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>StyleSheet</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Help</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::FileChooser</class>
<extends>QWidget</extends>
<header>Gui/FileDialog.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefFileChooser</class>
<extends>Gui::FileChooser</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefRadioButton</class>
<extends>QRadioButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefLineEdit</class>
<extends>QLineEdit</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -99,6 +99,7 @@ GENERATE_QM = {
"Material",
"OpenSCAD",
"Tux",
"Help",
}
# locations list contains Module name, relative path to translation folder and relative path to qrc file
@@ -128,6 +129,7 @@ locations = [
"../Mod/Fem/Gui/Resources/Fem.qrc",
],
["FreeCAD", "../Gui/Language", "../Gui/Language/translation.qrc"],
["Help", "../Mod/Help/Resources/translations", "../Mod/Help/Resources/Help.qrc"],
[
"Inspection",
"../Mod/Inspection/Gui/Resources/translations",

View File

@@ -172,6 +172,11 @@ directories = [
"workingdir": "./src/Mod/Web/",
"tsdir": "Gui/Resources/translations",
},
{
"tsname": "Help",
"workingdir": "./src/Mod/Help/",
"tsdir": "Resources/translations",
},
]
# Exclude these files from consideration