p-n junctions based on vertically stacked single or few-layer transition metal dichalcogenides (TMDCs) have attracted substantial scientific interest. Due to the propensity of TMDCs to show exclusively one type of conductivity, n- or p-type, heterojunctions of different materials are typically fabricated to produce diode-like current rectification and photovoltaic response. Recently, artificial, stable and substitutional doping of MoS2 into n- and p-type materials has been demonstrated. MoS2 is an interesting material for use in optoelectronic applications due to its potential of low-cost production in large quantities, strong light-matter interactions and chemical stability. Here we report the characterization of the optoelectronic properties of vertical homojunctions made by stacking few-layer flakes of MoS2:Fe (n-type) and MoS2:Nb (p-type). The junctions exhibit a peak external quantum efficiency of 4.7% and a maximum open circuit voltage of 0.51 V; they are stable in air; and their rectification characteristics and photovoltaic response are in excellent agreement with the Shockley diode model. The gate-tunability of the maximum output power, the ideality factor and the shunt resistance indicate that the dark current is dominated by trap-assisted recombination and that the photocurrent collection depends strongly on the spatial extent of the space charge region. We demonstrate a response time faster than 80 ms and highlight the potential to integrate such devices into quasi-transparent and flexible optoelectronics.