diff --git a/.gitignore b/.gitignore index fffd3eb3a0..997cd7b7f0 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ common/template_fieldnames_lexer.h eeschema/schematic_keywords.* pcbnew/pcb_plot_params_keywords.cpp pcbnew/pcb_plot_params_lexer.h -pcbnew/dialogs/panel_setup_rules_help_txt.h +pcbnew/dialogs/panel_setup_rules_help_md.h Makefile CMakeCache.txt auto_renamed_to_cpp @@ -109,4 +109,3 @@ CMakeSettings.json # KDevelop .kdev4/ *.kdev4 - diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 3d2db2ebbf..98f11eda06 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -585,21 +585,21 @@ else() endif() -# Create a C++ compilable string initializer containing text into a *.h file: +# Create a C++ compilable string initializer containing markdown text into a *.h file: add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dialogs/panel_setup_rules_help_txt.h + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dialogs/panel_setup_rules_help_md.h COMMAND ${CMAKE_COMMAND} - -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help.txt - -DoutputFile=${CMAKE_CURRENT_BINARY_DIR}/dialogs/panel_setup_rules_help_txt.h - -P ${CMAKE_MODULE_PATH}/Txt2C.cmake - DEPENDS ${CMAKE_MODULE_PATH}/Txt2C.cmake ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help.txt - COMMENT "creating ${CMAKE_CURRENT_BINARY_DIR}/dialogs/panel_setup_rules_help_txt.h - from ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help.txt" + -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help.md + -DoutputFile=${CMAKE_CURRENT_BINARY_DIR}/dialogs/panel_setup_rules_help_md.h + -P ${CMAKE_MODULE_PATH}/markdown2C.cmake + DEPENDS ${CMAKE_MODULE_PATH}/markdown2C.cmake ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help.md + COMMENT "creating ${CMAKE_CURRENT_BINARY_DIR}/dialogs/panel_setup_rules_help_md.h + from ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help.md" ) set_source_files_properties( dialogs/panel_setup_rules.cpp PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dialogs/panel_setup_rules_help_txt.h + OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dialogs/panel_setup_rules_help_md.h ) if( APPLE ) @@ -723,6 +723,7 @@ set( PCBNEW_KIFACE_LIBRARIES tinyspline_lib idf3 nanosvg + markdown_lib ${PCBNEW_IO_LIBRARIES} ${wxWidgets_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES} diff --git a/pcbnew/dialogs/panel_setup_rules.cpp b/pcbnew/dialogs/panel_setup_rules.cpp index 170399be15..4a82bb5c5f 100644 --- a/pcbnew/dialogs/panel_setup_rules.cpp +++ b/pcbnew/dialogs/panel_setup_rules.cpp @@ -35,6 +35,7 @@ #include #include #include +#include PANEL_SETUP_RULES::PANEL_SETUP_RULES( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) : PANEL_SETUP_RULES_BASE( aParent->GetTreebook() ), @@ -440,7 +441,7 @@ bool PANEL_SETUP_RULES::TransferDataFromWindow() void PANEL_SETUP_RULES::OnSyntaxHelp( wxHyperlinkEvent& aEvent ) { wxString msg = -#include "dialogs/panel_setup_rules_help_txt.h" +#include "dialogs/panel_setup_rules_help_md.h" ; #ifdef __WXMAC__ @@ -450,6 +451,9 @@ void PANEL_SETUP_RULES::OnSyntaxHelp( wxHyperlinkEvent& aEvent ) m_helpDialog = new HTML_MESSAGE_BOX( nullptr, _( "Syntax Help" ) ); m_helpDialog->SetDialogSizeInDU( 320, 320 ); - m_helpDialog->AddHTML_Text( "
" + EscapedHTML( msg ) + "
" ); + wxString html_txt; + ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt ); + m_helpDialog->m_htmlWindow->AppendToPage( html_txt ); + m_helpDialog->ShowModeless(); } diff --git a/pcbnew/dialogs/panel_setup_rules_help.md b/pcbnew/dialogs/panel_setup_rules_help.md new file mode 100644 index 0000000000..0360b8cb4a --- /dev/null +++ b/pcbnew/dialogs/panel_setup_rules_help.md @@ -0,0 +1,118 @@ +# Top-level Clauses + + (version ) + + (rule ...) + + +# Rule Clauses + + (constraint ...) + + (condition "") + + (layer "") + + +# Constraint Types + + * annular_width + * clearance + * disallow + * hole + * track_width + + +# Item Types + + * buried_via + * graphic + * hole + * micro_via + * pad + * text + * track + * via + * zone + + +# Examples + + (rule "copper keepout" + (constraint disallow track via zone) + (condition "A.insideArea('zone3')")) + + + (rule "BGA neckdown" + (constraint track_width (min 0.2mm) (opt 0.25mm)) + (constraint clearance (min 0.05) (opt 0.08mm)) + (condition "A.insideCourtyard('U3')")) + + + (rule HV + (constraint clearance (min 1.5mm)) + (condition "A.NetClass == 'HV'")) + + + (rule HV + (layer outer) + (constraint clearance (min 1.5mm)) + (condition "A.NetClass == 'HV'")) + + + (rule HV_HV + # wider clearance between HV tracks + (constraint clearance (min "1.5mm + 2.0mm")) + (condition "A.NetClass == 'HV' && B.NetClass == 'HV'")) + + + (rule HV_unshielded + (constraint clearance (min 2mm)) + (condition "A.NetClass == 'HV' && !A.insideArea('Shield*'))) + + +# Notes + +Version clause must be the first clause. + +Rules should be ordered by specificity. Later rules take +precedence over earlier rules; once a matching rule is found +no further rules will be checked. + +Use Ctrl+/ to comment or uncomment line(s). + + + +# Expression functions + +All function parameters support simple wildcards ('*' and '?'). + +True if any part of A lies within the given footprint's courtyard. + + A.insideCourtyard('') + + +True if any part of A lies within the given zone's outline. + + A.insideArea('') + + +True if A has a hole which is plated. + + A.isPlated() + + +True if A is a member of the given group. Includes nested membership. + + A.memberOf('') + + +True if A exists on the given layer. The layer name can be +either the name assigned in Board Setup > Board Editor Layers or +the canonical name (ie: F.Cu). + + A.onLayer('') + +NB: this returns true if `A` is on the given layer, independently +of whether or not the rule is being evaluated for that layer. +For the latter use a `(layer "layer_name")` clause in the rule. diff --git a/pcbnew/dialogs/panel_setup_rules_help.txt b/pcbnew/dialogs/panel_setup_rules_help.txt deleted file mode 100644 index 619c6ac5e0..0000000000 --- a/pcbnew/dialogs/panel_setup_rules_help.txt +++ /dev/null @@ -1,101 +0,0 @@ -# ---- Top-level Clauses - -(version ) -(rule ...) - - -# ---- Rule Clauses - -(constraint ...) -(condition "") -(layer "") - - -# ---- Constraint Types - -clearance annular_width track_width hole dissallow - - -# ---- Item Types - -track via micro_via buried_via -pad hole graphic text zone - - -# ---- Examples - -(rule "copper keepout" - (constraint disallow track via zone) - (condition "A.insideArea('zone3')")) - -(rule "BGA neckdown" - (constraint track_width (min 0.2mm) (opt 0.25mm)) - (constraint clearance (min 0.05) (opt 0.08mm)) - (condition "A.insideCourtyard('U3')")) - -(rule HV - (constraint clearance (min 1.5mm)) - (condition "A.NetClass == 'HV'")) - -(rule HV - (layer outer) - (constraint clearance (min 1.5mm)) - (condition "A.NetClass == 'HV'")) - -(rule HV_HV - # wider clearance between HV tracks - (constraint clearance (min "1.5mm + 2.0mm")) - (condition "A.NetClass == 'HV' && B.NetClass == 'HV'")) - -(rule HV_unshielded - (constraint clearance (min 2mm)) - (condition "A.NetClass == 'HV' && !A.insideArea('Shield*'))) - - -# ---- Notes -# -# Version clause must be the first clause. -# -# Rules should be ordered by specificity. Later rules take -# precedence over earlier rules; once a matching rule is found -# no further rules will be checked. -# -# Use Ctrl+/ to comment or uncomment line(s). -# - - -# ---- Expression functions -# -# All function parameters support simple wildcards ('*' and '?'). -# - -# True if any part of A lies within the given footprint's courtyard. - -A.insideCourtyard('') - - -# True if any part of A lies within the given zone's outline. - -A.insideArea('') - - -# True if A has a hole which is plated. - -A.isPlated() - - -# True if A is a member of the given group. Includes nested -# membership. - -A.memberOf('') - - -# True if A exists on the given layer. The layer name can be -# either the name assigned in Board Setup > Board Editor Layers or -# the canonical name (ie: F.Cu). -# -# NB: this returns true if A is on the given layer, independently -# of whether or not the rule is being evaluated for that layer. -# For the latter use a (layer "layer_name") clause in the rule. - -A.onLayer('') diff --git a/qa/pcbnew/CMakeLists.txt b/qa/pcbnew/CMakeLists.txt index 81fd08d2d5..fa8eb9c4d2 100644 --- a/qa/pcbnew/CMakeLists.txt +++ b/qa/pcbnew/CMakeLists.txt @@ -82,6 +82,7 @@ target_link_libraries( qa_pcbnew nanosvg idf3 unit_test_utils + markdown_lib ${PCBNEW_IO_LIBRARIES} ${wxWidgets_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES} diff --git a/qa/pcbnew_tools/CMakeLists.txt b/qa/pcbnew_tools/CMakeLists.txt index bfd290dacf..8da07b2141 100644 --- a/qa/pcbnew_tools/CMakeLists.txt +++ b/qa/pcbnew_tools/CMakeLists.txt @@ -59,6 +59,7 @@ target_link_libraries( qa_pcbnew_tools common qa_utils unit_test_utils + markdown_lib ${PCBNEW_IO_LIBRARIES} ${wxWidgets_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES}