doc: Port the shape images to the doc example system

This commit is contained in:
Emmanuel Lepage Vallee 2016-05-23 00:26:13 -04:00
parent feb3833fd1
commit 44a4eca40e
20 changed files with 17 additions and 71 deletions

View File

@ -300,9 +300,6 @@ if(GENERATE_DOC)
# Load the common documentation # Load the common documentation
include(docs/load_ldoc.cmake) 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 # 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 file is a valid CMakeLists.txt and can be executed directly if only
# the image artefacts are needed. # the image artefacts are needed.

View File

@ -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

View File

@ -28,7 +28,7 @@ local module = {}
--- Add a rounded rectangle to the current path. --- Add a rounded rectangle to the current path.
-- Note: If the radius is bigger than either half side, it will be reduced. -- 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 -- @param cr A cairo content
-- @tparam number width The rectangle width -- @tparam number width The rectangle width
@ -53,7 +53,7 @@ end
--- Add a rectangle delimited by 2 180 degree arcs to the path. --- 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 cr A cairo content
-- @param width The rectangle width -- @param width The rectangle width
@ -64,7 +64,7 @@ end
--- A rounded rect with only some of the corners rounded. --- 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 -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -117,7 +117,7 @@ end
--- A rounded rectangle with a triangle at the top. --- A rounded rectangle with a triangle at the top.
-- --
-- @SHAPE_infobubble_EXAMPLE@ -- @DOC_gears_shape_infobubble_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -152,7 +152,7 @@ end
--- A rectangle terminated by an arrow. --- A rectangle terminated by an arrow.
-- --
-- @SHAPE_rectangular_tag_EXAMPLE@ -- @DOC_gears_shape_rectangular_tag_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -179,7 +179,7 @@ end
--- A simple arrow shape. --- A simple arrow shape.
-- --
-- @SHAPE_arrow_EXAMPLE@ -- @DOC_gears_shape_arrow_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -206,7 +206,7 @@ end
--- A squeezed hexagon filling the rectangle. --- A squeezed hexagon filling the rectangle.
-- --
-- @SHAPE_hexagon_EXAMPLE@ -- @DOC_gears_shape_hexagon_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -224,7 +224,7 @@ end
--- Double arrow popularized by the vim-powerline module. --- Double arrow popularized by the vim-powerline module.
-- --
-- @SHAPE_powerline_EXAMPLE@ -- @DOC_gears_shape_powerline_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -252,7 +252,7 @@ end
--- An isosceles triangle. --- An isosceles triangle.
-- --
-- @SHAPE_isosceles_triangle_EXAMPLE@ -- @DOC_gears_shape_isosceles_triangle_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -266,7 +266,7 @@ end
--- A cross (**+**) symbol. --- A cross (**+**) symbol.
-- --
-- @SHAPE_cross_EXAMPLE@ -- @DOC_gears_shape_cross_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -293,7 +293,7 @@ end
--- A similar shape to the `rounded_rect`, but with sharp corners. --- A similar shape to the `rounded_rect`, but with sharp corners.
-- --
-- @SHAPE_octogon_EXAMPLE@ -- @DOC_gears_shape_octogon_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -316,7 +316,7 @@ end
--- A circle shape. --- A circle shape.
-- --
-- @SHAPE_circle_EXAMPLE@ -- @DOC_gears_shape_circle_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -329,7 +329,7 @@ end
--- A simple rectangle. --- A simple rectangle.
-- --
-- @SHAPE_rectangle_EXAMPLE@ -- @DOC_gears_shape_rectangle_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @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 --- A diagonal parallelogram with the bottom left corner at x=0 and top right
-- at x=width. -- at x=width.
-- --
-- @SHAPE_parallelogram_EXAMPLE@ -- @DOC_gears_shape_parallelogram_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @tparam number width The shape width
@ -358,7 +358,7 @@ end
--- A losange. --- A losange.
-- --
-- @SHAPE_losange_EXAMPLE@ -- @DOC_gears_shape_losange_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number width The shape width -- @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 -- Note that this shape is not closed and thus filling it doesn't make much
-- sense. -- sense.
-- --
-- @SHAPE_radial_progress_EXAMPLE@ -- @DOC_gears_shape_radial_progress_EXAMPLE@
-- --
-- @param cr A cairo context -- @param cr A cairo context
-- @tparam number w The shape width -- @tparam number w The shape width

View File

@ -30,7 +30,7 @@ local function show(cr, skip_fill)
cr:clip() cr:clip()
end end
local cr = get_surface(svgpath) local cr = get_surface(svgpath..".svg")
cr:translate(3,3) cr:translate(3,3)
loadfile(filepath)(shape, cr, show) loadfile(filepath)(shape, cr, show)