sphinx-pcbdraw

This is a basic Sphinx extension for creating board views from KiCAD .kicad_pcb files and embedding them into a Sphinx document. Utilizes PcbDraw created by yaqwsx. Requires KiCAD and KiKit.

pcbdraw directive

Here are some examples.

.. pcbdraw:: UPduino_v3.0.kicad_pcb
_images/UPduino_v3.0.kicad_pcb.svg
.. pcbdraw:: UPduino_v3.0.kicad_pcb
   :back:
   :mirror:
   :placeholder:
   :no-drillholes:
_images/UPduino_v3.0.kicad_pcb_placeholder_no-drillholes_back_mirror.svg
.. pcbdraw:: NINA-W102_minimal_breakout.kicad_pcb
_images/NINA-W102_minimal_breakout.kicad_pcb.svg
.. pcbdraw:: ThisFileDoesntExist.kicad_pcb

Error

sphinx-pcbdraw: File does not exist: ThisFileDoesntExist.kicad_pcb

options

.. pcbdraw:: path/to/pcb.kicad_pcb
   :style: path/to/style.json           # select a path/to/style.json
   # or selects a builtin style if not a proper path
   :placeholder:                        # place red squares in place of missing components
   :remap: path/to/remap.json           # use path/to/remap.json to remap components
   :no-drillholes:                      # don't make drillholes transparent
   :back:                               # draw the back of the board
   :mirror:                             # mirror board on x-axis
   :highlight: comma, separated, list   # highlight these components
   :filter: comma, separated, list      # only show these components
   :hidden: comma, separated, list      # don't show these components
   :width:                              # width of the resulting image, defaults to 100%

pcb-components directive

A list of all the components on a board can be created using this directive. It will default to only showing the components on the front side:

.. pcb-components:: UPduino_v3.0.kicad_pcb
LibraryComponent
Capacitor_SMDC_0603_1608Metric
Connector_PinHeader_2.54mmPinHeader_1x02_P2.54mm_Vertical
FiducialFiducial_0.75mm_Mask1.5mm
Inductor_SMDL_0603_1608Metric
LED_SMDLED_0603_1608Metric
Package_DFN_QFNQFN-48-1EP_7x7mm_P0.5mm_EP5.6x5.6mm
Package_SOSOIC-8_5.23x5.23mm_P1.27mm
Resistor_SMDR_0603_1608Metric
TestPointTestPoint_Pad_D1.0mm
VS.preetyLED_Cree-PLCC4_2x2mm_CW
vsMountingHole_2.5mm_M3
vsOscillator_SMD_Abracon_ASDMB-4Pin_2.5x2.0mm
vsPinHeader_1x24_P2.54mm_Vertical
vsQFN-48-1EP_8x8mm_P0.5mm_EP6.2x6.2mm
vsSOT-23-6
vsShortedJumper-2_P1.3mm_Bridged_Pad1.0x1.0mm
vsSolderJumper-2_0603_Open_TrianglePad1.0x1.5mm
vsTiny4
vsUSB_Micro_AB_Female_0475890001

Components from only the back side can be specified:

.. pcb-components:: UPduino_v3.0.kicad_pcb
   :side: back
LibraryComponent
Capacitor_SMDC_0603_1608Metric
Diode_SMDD_SOD-523
FiducialFiducial_0.75mm_Mask1.5mm
Inductor_SMDL_0603_1608Metric
Package_SOVSSOP-8_2.3x2mm_P0.5mm
Resistor_SMDR_0603_1608Metric
SymbolWEEE-Logo_4.2x6mm_SilkScreen
TestPointTestPoint_Pad_D1.0mm
vsSOT-23-5
vsShortedJumper-2_P1.3mm_Bridged_Pad1.0x1.0mm
vsSolderJumper-2_0603_Open_TrianglePad1.0x1.5mm

Components from both sides can be specificed.:

.. pcb-components:: NINA-W102_minimal_breakout.kicad_pcb
   :side: both
LibraryComponent
6_PIN_SERIAL_TARGET_SIDE_W_SILK
AestheticsOSHW-LOGO-MINI
Capacitors_SMDC_1206_HandSoldering
LEDsLED_1206_HandSoldering
Resistors_SMDR_1206_HandSoldering
lib1X15_LOCK
libBREADBOARD_SPACING_80mm
libDuckTapeApproved-MIT
libGDG-logo-mono-withouttext-h5.6
libMakeZurich-15x11-silk
libNINA-W102
libSMT-JUMPER_2_NC_TRACE_SILK
switchessiliconeTACTILE_SWITCH_SMD_6.0X6.0MM

TODO

pcbdraw global options

sphinx_pcbdraw_libs = ["lib/folder/one", "lib/folder/two"] # library folders to include for generation
sphinx_pcbdraw_style = "path/to/style.json" # default style path or builtin
sphinx_pcbdraw_remap = "path/to/remap.json" # default for remapping components
sphinx_pcbdraw_hidden = ["component1", "component2"] # list of components to hide from all designs

License

sphinx-pcbdraw is under the MIT license. Source code is avaiable at https://github.com/nobodywasishere/sphinx-pcbdraw.

Example kicad_pcb file UPduino_v3.0.kicad_pcb from https://github.com/tinyvision-ai-inc/UPduino-v3.0, Copyright tinyvision-ai-inc under the MIT License.

Example kicad_pcb file NINA-W102_minimal_breakout.kicad_pcb from https://github.com/rac2030/breakout-boards, Copyright Michel Racic under the MIT License.