diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index 83f0f5bf..7f2fd5d1 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -300,9 +300,6 @@ if(GENERATE_DOC) # Load the common documentation include(docs/load_ldoc.cmake) - # Generate some images and examples - include(docs/generate_examples.cmake) - # Use `include`, rather than `add_subdirectory`, to keep the variables # The file is a valid CMakeLists.txt and can be executed directly if only # the image artefacts are needed. diff --git a/docs/generate_examples.cmake b/docs/generate_examples.cmake deleted file mode 100644 index bb2d0716..00000000 --- a/docs/generate_examples.cmake +++ /dev/null @@ -1,51 +0,0 @@ - -# Get and update the LUA_PATH so the scripts can be executed without Awesome -execute_process(COMMAND lua -e print\(package.path\) OUTPUT_VARIABLE LUA_PATH_) -set(ENV{LUA_PATH} "${SOURCE_DIR}/lib/?;${SOURCE_DIR}/lib/?.lua;${LUA_PATH_}") - -file(MAKE_DIRECTORY "${BUILD_DIR}/doc/images") - -set(ENV{BUILD_DIRECTORY} "${BUILD_DIR}/") -set(ENV{AWESOME_LIB_DIR} "${SOURCE_DIR}/lib/") - -# -# Shape API -# -foreach (SHAPE_NAME "circle" "arrow" "rounded_rect" "hexagon" "infobubble" - "powerline" "isosceles_triangle" "cross" "octogon" "parallelogram" - "losange" "partially_rounded_rect" "radial_progress" "rounded_bar" - "rectangle" "rectangular_tag") - set(SHAPE_FILE "${SOURCE_DIR}/tests/shape/${SHAPE_NAME}.lua") - set(SHAPE_SVG "${BUILD_DIR}/doc/images/shape_${SHAPE_NAME}.svg") - - # Generate some SVG for the documentation and load the examples for the doc - execute_process( - COMMAND lua ${SOURCE_DIR}/tests/shape/test-shape.lua ${SHAPE_FILE} ${SHAPE_SVG} ${SOURCE_DIR}/.luacov - ERROR_VARIABLE SHAPE_ERROR - ) - - if (NOT SHAPE_ERROR STREQUAL "") - message(${SHAPE_ERROR}) - message(FATAL_ERROR ${SHAPE_NAME} " SVG generation failed, bye") - endif() - - # Set the SVG paths for the doc - set(SHAPE_${SHAPE_NAME}_SVG "../images/shape_${SHAPE_NAME}.svg") - - # Use the .lua as code example - file(READ ${SHAPE_FILE} SHAPE_EXAMPLE) - STRING(REGEX REPLACE "\n" ";" SHAPE_EXAMPLE "${SHAPE_EXAMPLE}") - SET(SHAPE_COMMENTED - "![Shape example](../images/shape_${SHAPE_NAME}.svg)\n--\n-- @usage" - ) - foreach (EXAMPLE_FILE ${SHAPE_EXAMPLE}) - if(NOT EXAMPLE_FILE MATCHES "^.+--DOC_HIDE$") - SET(SHAPE_COMMENTED ${SHAPE_COMMENTED}\n--${EXAMPLE_FILE}) - endif() - endforeach() - - set(SHAPE_${SHAPE_NAME}_EXAMPLE ${SHAPE_COMMENTED}) - -endforeach() - -# vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker diff --git a/lib/gears/shape.lua b/lib/gears/shape.lua index f6c0d468..a7de80c4 100644 --- a/lib/gears/shape.lua +++ b/lib/gears/shape.lua @@ -28,7 +28,7 @@ local module = {} --- Add a rounded rectangle to the current path. -- Note: If the radius is bigger than either half side, it will be reduced. -- --- @SHAPE_rounded_rect_EXAMPLE@ +-- @DOC_gears_shape_rounded_rect_EXAMPLE@ -- -- @param cr A cairo content -- @tparam number width The rectangle width @@ -53,7 +53,7 @@ end --- Add a rectangle delimited by 2 180 degree arcs to the path. -- --- @SHAPE_rounded_bar_EXAMPLE@ +-- @DOC_gears_shape_rounded_bar_EXAMPLE@ -- -- @param cr A cairo content -- @param width The rectangle width @@ -64,7 +64,7 @@ end --- A rounded rect with only some of the corners rounded. -- --- @SHAPE_partially_rounded_rect_EXAMPLE@ +-- @DOC_gears_shape_partially_rounded_rect_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -117,7 +117,7 @@ end --- A rounded rectangle with a triangle at the top. -- --- @SHAPE_infobubble_EXAMPLE@ +-- @DOC_gears_shape_infobubble_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -152,7 +152,7 @@ end --- A rectangle terminated by an arrow. -- --- @SHAPE_rectangular_tag_EXAMPLE@ +-- @DOC_gears_shape_rectangular_tag_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -179,7 +179,7 @@ end --- A simple arrow shape. -- --- @SHAPE_arrow_EXAMPLE@ +-- @DOC_gears_shape_arrow_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -206,7 +206,7 @@ end --- A squeezed hexagon filling the rectangle. -- --- @SHAPE_hexagon_EXAMPLE@ +-- @DOC_gears_shape_hexagon_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -224,7 +224,7 @@ end --- Double arrow popularized by the vim-powerline module. -- --- @SHAPE_powerline_EXAMPLE@ +-- @DOC_gears_shape_powerline_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -252,7 +252,7 @@ end --- An isosceles triangle. -- --- @SHAPE_isosceles_triangle_EXAMPLE@ +-- @DOC_gears_shape_isosceles_triangle_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -266,7 +266,7 @@ end --- A cross (**+**) symbol. -- --- @SHAPE_cross_EXAMPLE@ +-- @DOC_gears_shape_cross_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -293,7 +293,7 @@ end --- A similar shape to the `rounded_rect`, but with sharp corners. -- --- @SHAPE_octogon_EXAMPLE@ +-- @DOC_gears_shape_octogon_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -316,7 +316,7 @@ end --- A circle shape. -- --- @SHAPE_circle_EXAMPLE@ +-- @DOC_gears_shape_circle_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -329,7 +329,7 @@ end --- A simple rectangle. -- --- @SHAPE_rectangle_EXAMPLE@ +-- @DOC_gears_shape_rectangle_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -341,7 +341,7 @@ end --- A diagonal parallelogram with the bottom left corner at x=0 and top right -- at x=width. -- --- @SHAPE_parallelogram_EXAMPLE@ +-- @DOC_gears_shape_parallelogram_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -358,7 +358,7 @@ end --- A losange. -- --- @SHAPE_losange_EXAMPLE@ +-- @DOC_gears_shape_losange_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number width The shape width @@ -377,7 +377,7 @@ end -- Note that this shape is not closed and thus filling it doesn't make much -- sense. -- --- @SHAPE_radial_progress_EXAMPLE@ +-- @DOC_gears_shape_radial_progress_EXAMPLE@ -- -- @param cr A cairo context -- @tparam number w The shape width diff --git a/tests/shape/arrow.lua b/tests/examples/gears/shape/arrow.lua similarity index 100% rename from tests/shape/arrow.lua rename to tests/examples/gears/shape/arrow.lua diff --git a/tests/shape/circle.lua b/tests/examples/gears/shape/circle.lua similarity index 100% rename from tests/shape/circle.lua rename to tests/examples/gears/shape/circle.lua diff --git a/tests/shape/cross.lua b/tests/examples/gears/shape/cross.lua similarity index 100% rename from tests/shape/cross.lua rename to tests/examples/gears/shape/cross.lua diff --git a/tests/shape/hexagon.lua b/tests/examples/gears/shape/hexagon.lua similarity index 100% rename from tests/shape/hexagon.lua rename to tests/examples/gears/shape/hexagon.lua diff --git a/tests/shape/infobubble.lua b/tests/examples/gears/shape/infobubble.lua similarity index 100% rename from tests/shape/infobubble.lua rename to tests/examples/gears/shape/infobubble.lua diff --git a/tests/shape/isosceles_triangle.lua b/tests/examples/gears/shape/isosceles_triangle.lua similarity index 100% rename from tests/shape/isosceles_triangle.lua rename to tests/examples/gears/shape/isosceles_triangle.lua diff --git a/tests/shape/losange.lua b/tests/examples/gears/shape/losange.lua similarity index 100% rename from tests/shape/losange.lua rename to tests/examples/gears/shape/losange.lua diff --git a/tests/shape/octogon.lua b/tests/examples/gears/shape/octogon.lua similarity index 100% rename from tests/shape/octogon.lua rename to tests/examples/gears/shape/octogon.lua diff --git a/tests/shape/parallelogram.lua b/tests/examples/gears/shape/parallelogram.lua similarity index 100% rename from tests/shape/parallelogram.lua rename to tests/examples/gears/shape/parallelogram.lua diff --git a/tests/shape/partially_rounded_rect.lua b/tests/examples/gears/shape/partially_rounded_rect.lua similarity index 100% rename from tests/shape/partially_rounded_rect.lua rename to tests/examples/gears/shape/partially_rounded_rect.lua diff --git a/tests/shape/powerline.lua b/tests/examples/gears/shape/powerline.lua similarity index 100% rename from tests/shape/powerline.lua rename to tests/examples/gears/shape/powerline.lua diff --git a/tests/shape/radial_progress.lua b/tests/examples/gears/shape/radial_progress.lua similarity index 100% rename from tests/shape/radial_progress.lua rename to tests/examples/gears/shape/radial_progress.lua diff --git a/tests/shape/rectangle.lua b/tests/examples/gears/shape/rectangle.lua similarity index 100% rename from tests/shape/rectangle.lua rename to tests/examples/gears/shape/rectangle.lua diff --git a/tests/shape/rectangular_tag.lua b/tests/examples/gears/shape/rectangular_tag.lua similarity index 100% rename from tests/shape/rectangular_tag.lua rename to tests/examples/gears/shape/rectangular_tag.lua diff --git a/tests/shape/rounded_bar.lua b/tests/examples/gears/shape/rounded_bar.lua similarity index 100% rename from tests/shape/rounded_bar.lua rename to tests/examples/gears/shape/rounded_bar.lua diff --git a/tests/shape/rounded_rect.lua b/tests/examples/gears/shape/rounded_rect.lua similarity index 100% rename from tests/shape/rounded_rect.lua rename to tests/examples/gears/shape/rounded_rect.lua diff --git a/tests/shape/test-shape.lua b/tests/examples/gears/shape/template.lua similarity index 96% rename from tests/shape/test-shape.lua rename to tests/examples/gears/shape/template.lua index b15cbab0..86fcc467 100644 --- a/tests/shape/test-shape.lua +++ b/tests/examples/gears/shape/template.lua @@ -30,7 +30,7 @@ local function show(cr, skip_fill) cr:clip() end -local cr = get_surface(svgpath) +local cr = get_surface(svgpath..".svg") cr:translate(3,3) loadfile(filepath)(shape, cr, show)