File tree Expand file tree Collapse file tree 1 file changed +43
-1
lines changed
md-render/HHVM/UserDocumentation Expand file tree Collapse file tree 1 file changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,49 @@ def call
51
51
File . read ( full_path ) ,
52
52
language : 'Hack' ,
53
53
) ;
54
- node . replace ( code )
54
+ code_node = node . replace ( code )
55
+ # If the example has HHVM output associated with it, then print it
56
+ # after the code example. However, if both a .example.hhvm.out and
57
+ # .hhvm.expect exist, that is an error
58
+ output_header = doc . document . create_element (
59
+ 'em' ,
60
+ "Output" ,
61
+ ) ;
62
+ if ( File . exists? ( full_path + ".hhvm.expect" ) ) ^ ( File . exists? ( full_path + ".example.hhvm.out" ) )
63
+ if File . exists? ( full_path + ".hhvm.expect" )
64
+ output_path = full_path + ".hhvm.expect"
65
+ else
66
+ output_path = full_path + ".example.hhvm.out"
67
+ end
68
+ output = doc . document . create_element (
69
+ 'pre' ,
70
+ File . read ( output_path ) ,
71
+ language : 'Text' ,
72
+ ) ;
73
+ code_node . after ( output ) . after ( output_header )
74
+ elsif ( File . exists? ( full_path + ".hhvm.expect" ) ) && ( File . exists? ( full_path + ".example.hhvm.out" ) )
75
+ text = "Both .hhvm.expect and .example.hhvm.out exist. Remove one: #{ full_path } "
76
+ STDERR . write (
77
+ text . red . bold + "\n "
78
+ )
79
+ warning = doc . document . create_element (
80
+ 'h1' ,
81
+ text ,
82
+ style : 'color: red' ,
83
+ )
84
+ code_node . after ( warning ) . after ( output_header )
85
+ elsif File . exists? ( full_path + ".hhconfig" ) # We have some include .php files that we don't want output for. Files that are test run have a .hhconfig
86
+ text = "Neither .hhvm.expect or .example.hhvm.out exist. Add one: #{ full_path } "
87
+ STDERR . write (
88
+ text . red . bold + "\n "
89
+ )
90
+ warning = doc . document . create_element (
91
+ 'h1' ,
92
+ text ,
93
+ style : 'color: red' ,
94
+ )
95
+ code_node . after ( warning ) . after ( output_header )
96
+ end
55
97
end
56
98
doc
57
99
end
You can’t perform that action at this time.
0 commit comments