The development of shear capacity equations for reinforced concrete (RC) beams and columns has been historically pursued starting from the conceptualization of a resisting mechanism. Recently, machine learning techniques are attracting more and more interest in this field. Mechanics-based and data-driven approaches (i.e., white box and black box modeling, respectively) have been considered independently so far. Conversely, this work aims at exploring a hybrid alternative way (i.e., gray box modeling) for deriving the shear capacity equation for RC beams and columns, in which a mechanics-based code-conforming formulation is improved thanks to a machine-learning-aided approach. Specifically, the capacity equation currently in use within Europe that relies on the variable-angle truss resisting mechanism is enriched by means of Genetic Programming. Easy-to-use novel expressions for the two fundamental coefficients ruling the concrete contribution are defined to better match experimental data. The performance of the newly obtained equation is first discussed within the largest comparative assessment ever presented so far among shear strength formulations reported into existing technical codes around the world. Afterward, it is recast into a code-formatted design capacity equation using a simple, yet reliable, procedure. Overall, the results demonstrate that merging mechanics-based and data-driven methods can be beneficial in the development of capacity equations since it allows preserving the physical meaning of the resisting mechanism while enhancing the accuracy of the final predictions by means of machine learning techniques. Although the methodology is here applied to evaluate the shear strength of RC beams and columns, it is very general and can be readily extended to the development of further capacity equations.